在CentOS 6.5下的virtualenvwrapper的使用

来源:互联网 发布:usb高速数据采集卡 编辑:程序博客网 时间:2024/05/21 20:21

1,先yum intall virtualenv

2,然后pip install virtualenvwrapper

安装完需要配置:

vim ~/.bash_profile

下面代码添加到后面

Shell Startup File

Add three lines to your shell startup file (.bashrc, .profile, etc.) to set the location where the virtual environments should live, the location of your development project directories, and the location of the script installed with this package:

#virtualenvwrapper export WORKON_HOME=$HOME/virtualenvs # 虚拟环境存放位置自己指定 source /usr/bin/virtualenvwrapper.sh # 指定virtualenvwrapper的执行文件路径export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python # 系统python2.7执行文件位置,根据自己环境而定 export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' # 启动时候指定参数,就是我们用的独立于系统的安装包 export PIP_VIRTUALENV_BASE=$WORKON_HOME # 告知pip virtualenv的位置 export PIP_RESPECT_VIRTUALENV=true # 执行pip的时候让系统自动开启虚拟环境 


After editing it, reload the startup file (e.g., run source ~/.bashrc).

执行:

source ~/.bash_profile

这里我没理解,我直接在shell里运行这三个命令也是可以的


-------------------------------------------------------------------------------------------------------------------------安装和配置完了


下面是使用:

mkvirtualenv demo1workon 切换到环境deactivate 注销当前环境lsvirtualenv 列出所有环境rmvirtualenv 删除环境cpvirtualenv 复制环境cdsitepackages cd到当前环境的site-packages目录lssitepackages 列出当前环境中site-packages内容setvirtualenvproject 绑定现存的项目和环境wipeenv 清除环境内所有第三方包


0 0