利用pyenv 实现python 多版本切换
下载
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
安装支持包
yum install zlib-devel openssl-devel sqlite-devel patch
增加配置:.bash_profile
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
安装3.6.1
pyenv install 3.6.1
安装2.7
pyenv install 2.7
如果系统最小化安装缺少,patch命令
Downloading Python-2.7.tgz...
-> https://www.python.org/ftp/python/2.7/Python-2.7.tgz
Installing Python-2.7...
/root/.pyenv/plugins/python-build/bin/python-build: line 1501: patch: command not found
BUILD FAILED (CentOS release 6.5 (Final) using python-build 20160602)
Inspect or clean up the working tree at /tmp/python-build.20170612214128.21462
Results logged to /tmp/python-build.20170612214128.21462.log
Last 10 log lines:
/tmp/python-build.20170612214128.21462 ~
/tmp/python-build.20170612214128.21462/Python-2.7 /tmp/python-build.20170612214128.21462
python2 、python3 安装完毕
查看当前python 版本:pyenv versions
system
2.7
* 3.6.1 (set by /root/.pyenv/version)
默认3.6.1,可以自行检查python版本,这里不做说明
切换到2.7版本 pyenv global 2.7
查看当前python 版本: pyenv versions
system
* 2.7 (set by /root/.pyenv/version)
3.6.1
其他常用命令:
pyenv install --list #查看可用安装版本,包含pytho、jpython、anaconda、miniconda...