安装virtualenv和virtualenvwrapper
pip install virtualenv
pip install virtualenvwrapper


创建存放虚拟环境的文件夹,并切换到文件夹下
mkdir .Envs

查看Python安装路径
which python3

修改环境变量
vim .bash_profile

export WORKON_HOME=~/.Envs
VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
source /Library/Frameworks/Python.framework/Versions/3.8/bin/virtualenvwrapper.sh
*记得其中VIRTUALENVWRAPPER_PYTHON source 后面替换成自己的路径

退出vim保存
source .bash_profile

mkvirtualenv test #创建 名为test的虚拟环境
deactivate #退出当前虚拟环境
workon test # 进入之前创建test的虚拟环境

网友评论