一、安装pyenv
参考:https://github.com/yyuu/pyenv-installer
$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
$ vim .bash_profile
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
$ source .bash_profile
$ pyenv update
二、使用pyenv安装python
$ pyenv install 2.7
$ pyenv versions
* system (set by /home/xxx/.pyenv/version)
2.7
三、使用virtualenv
1. 创建虚拟python环境
$ pyenv virtualenv 2.7 v_py27
$ pyenv verions
* system (set by /home/xxx/.pyenv/version)
2.7
v_py27
2. activate和deactivate
$ pyenv activate v_py27
$ pyenv deactivate
四、修改默认python环境
$ pyenv gobal v_py27