前提
安装Python3
安装virtualenv
pip3 install virtualenv
virtualenv的用法
安装virtualwrapper
pip3 install virtualenvwrapper
设置virtualenvwrapper
# python virtualenvwrapper
# virtualenvwrapper Setting
# Setting variable WORKON_HOME
export WORKON_HOME='~/.virtualenvs'
# Setting variable VIRTUALENVWRAPPER_PYTHON to locate python3 where virtualenvwrapper is installed.
export VIRTUALENVWRAPPER_PYTHON='/Library/Frameworks/Python.framework/Versions/3.5/bin/python3'
# Initialize the virtualenvwrapper
source /Library/Frameworks/Python.framework/Versions/3.5/bin/virtualenvwrapper.sh
执行环境变量文件
source .bash_profile
virtualenvwrapper命令列表:
workon:列出虚拟环境列表
lsvirtualenv:同上
mkvirtualenv [envname]:新建虚拟环境
workon [envname]:切换虚拟环境
rmvirtualenv [envname]:删除虚拟环境
deactivate: 离开虚拟环境
cpvirtualenv [sorce] [dest] #复制虚拟环境
pip freeze > requirements.txt 导出该环境下所有依赖到requirements.txt文件
谢谢!
领取专属 10元无门槛券
私享最新 技术干货