1.作用
管理python解释器、python版本、python的虚拟环境
软件下载地址:https://github.com/pyenv/pyenv
2.pyenv软件包安装
a、配置yum源(配置文件内容如下)
vi CentOS6-Base-163.repo
[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
enable=1
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
gpgcheck=0
enable=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
gpgcheck=0
enable=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
gpgcheck=0
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
gpgcheck=0
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
b、安装git软件和依赖包
yum install git -y
yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline- devel zlib-devel bzip2-devel
c、创建用户
useradd python
passwd python
d、安装pyenv软件
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
e、配置环境变量
vim ~/.bash_profile
export PATH="/home/python/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
1.1.2 3.使用pyenv软件安装和管理python
a、列出所有可用版本
pyenv versions
b、安装指定python版本
pyenv install 3.5.3 -v
查看python版本
python -V
c、创建一个目录让local捆绑在一个目录下
mkdir -p magedu/projects
cd magedu/projects/
pyenv local 3.5.3----------------#让python版本捆绑在一个目录下
python -V
Python 3.5.3
cd-------#你看如果在其它目录,python版本就是系统默认的2.6,local登录基本做到隔离
python -V
Python 2.6.6
原文地址:http://blog.51cto.com/11310506/2060920