【ubuntu】安装pyenv
一、官网
https://github.com/pyenv/pyenv
二、作用
管理python版本和环境
三、安装
3.1、自动安装
1、一键安装
curl https://pyenv.run | bash
网要好,可能会下载失败
会下载四个插件
pyenv-doctor pyenv-update pyenv-virtualenv python-build
2、配置环境变量
vim ~/.bashrc
加入如下配置
# pyenv # Load pyenv automatically by appending # the following to # ~/.bash_profile if it exists, otherwise ~/.profile (for login shells) # and ~/.bashrc (for interactive shells) : export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" # Restart your shell for the changes to take effect. # Load pyenv-virtualenv automatically by adding # the following to ~/.bashrc: eval "$(pyenv virtualenv-init -)"
生效配置
source ~/.bashrc
3.2、手动安装
1、手动下发和编译插件(插件是可选项)
# Check out Pyenv where you want it installed. A good place to choose is $HOME/.pyenv (but you can install it somewhere else): git clone https://github.com/pyenv/pyenv.git ~/.pyenv # Optionally, try to compile a dynamic Bash extension to speed up Pyenv. Don't worry if it fails; Pyenv will still work normally: cd ~/.pyenv && src/configure && make -C src
手动安装插件
# 我们的pyenv的安装目录是/.pyenv,所以我们需要把pyenv-virtualenv克隆到/.pyenv/plugins下,执行下面的命令 git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
2、配置环境变量
vim ~/.bashrc
# pyenv # Load pyenv automatically by appending # the following to # ~/.bash_profile if it exists, otherwise ~/.profile (for login shells) # and ~/.bashrc (for interactive shells) : export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" # Restart your shell for the changes to take effect. # Load pyenv-virtualenv automatically by adding # the following to ~/.bashrc:
# 可选, 装了插件就配置,没装就不用配置 eval "$(pyenv virtualenv-init -)"
生效配置
source ~/.bashrc
四、更新
4.1 命令更新
pyenv update
4.2 手动更新
# To upgrade to the latest development version of pyenv, use git pull:
cd $(pyenv root)
git pull
五、卸载
5.1 删除安装目录
rm -rf ~/.pyenv
5.2 删除环境变量配置
就是自己添加的环境变量
六、使用方法
见另一篇文章
https://www.cnblogs.com/fireblackman/p/18588623
参考链接:
https://github.com/pyenv/pyenv