centos6.5安装virtualenv与virtualenvwrapper

一、工具准备

pip install virtualenv

pip install virtualenvwrapper

 

二、目录准备

1、虚拟环境工作目录

mkdir /home/workspaces

2、多版本工作目录

mkdir /home/share

mkdir /home/share/python27

mkdir /home/share/python34

 

三、配置工作

1、配置环境变量

export WORKON_HOME=/home/workspaces

source /usr/bin/virtualenvwrapper.sh

2、多版本Python安装

Centos6.5默认安装Python2.6.6

(1)下载

cd /tmp

wget http://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz

wget http://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz

(2)解压

tar –zxvf Python-3.4.3.tgz

tar –zxvf Python-2.7.9.tgz

(3)安装

cd  Python-3.4.3

./configure --prefix=/home/share/python34

make

make install

 

cd  Python-2.7.9

./configure --prefix=/home/share/python27

make

make install


3
、创建环境

mkvirtualenv env26

mkvirtualenv -p /home/share/python27/bin/python2.7 env27
mkvirtualenv -p /home/share/python34/bin/python3.4 env34

这样就分别建立了python2.7和3.4两个版本的虚拟环境

4、其他命令

 
启动虚拟环境
cd env
source bin/activate
切换工作目录workon env27
删除虚拟环境rmvirtualenv
展示虚拟环境lsvirtualenv
退出环境deactivate

 


你可能感兴趣的:(centos6.5安装virtualenv与virtualenvwrapper)