1. Install Virtualenv by pip
2. Install pyenv (recommended)
Install the relevant Environment pack:
#yum groupinstall "Development tools"
#yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel #readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
安装 pyenv
#curl https://raw.github.com/yyuu/pyenv-installer/master/bin/pyenv-installer |bash
或者
git clone git://github.com/yyuu/pyenv.git .pyenv #.pyenv 为虚拟目录
3.创建环境变量:
[Email protected] ~]# cat/etc/profile.d/pyenv.sh #!/bin/bash################ #export pyenv_root= "$HOME/.pyenv" Export path= "$PYENV _root/bin: $PATH" eval "$ (pyenv init-)" [[Email protected] ~] #source/etc/profile.d/pyenv.sh[[email Protected] ~]# cat ~/.pip/pip.conf #设置pip国内源 (optional); [Global]index-url = Http://pypi.douban.com/[[email protecte D] ~]#
4.测试
[[email protected] ~]# pyenv install --list #显示可安装的包 [[email protected ] ~]# pyenv install 3.4.3 #安装python3.4.3[[email protected] ~]# pyenv local system #本地切换系统默认的python版本 [[email protected] ~]# python -v # View the current version of the system python 2.7.5[[email protected] ~]# pyenv local 3.4.3 #本地切换python3.4.3 Version [[email protected] ~]# pyenv shell 3.4.3 #和上类似 [[email protected] ~]# python -vpython 3.4.3[[email Protected] ~] #pyenv global system[[email protected] ~]# pyenv versions #查看系统当前可用的python版本, and the version you are using system* 3.4.3 (set by /root/.python-versIon
Python multiple version management