## mac
###? 1.安装virtualenv 和virtualenvwrapper
pip3 install -i https://mirrors.aliyun.com/pypi/simple virtualenv
pip3 install -i https://mirrors.aliyun.com/pypi/simple virtualenvwrapper
注意:如果安装virtualenvwrapper 报错,一般执行:pip3 install --upgrade pip 即可
### 2.创建一个文件夹,用于存放虚拟环境? 例如:python_env
### 3.环境变量添加:vi ~/.bash_profile
export WORKON_HOME="/Users/yanghaoyang/python_envs"?
# which python 查看路径
export VIRTUALENVWRAPPER_PYTHON="/usr/local/bin/python3"?
# which?virtualenvwrapper.sh
source /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh
### 4. source??~/.bash_profile? 使之生效
### 5. 创建虚拟环境
mkvirtualenv env_test1
如果出现报错:ERROR: virtualenvwrapper could not find virtualenv in your path
解决方法:软链接 同样通过sudo find / -name 'virtualenv'可查找到路径
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenv /usr/local/bin/virtualenv
### 退出
deactivate
## windons
1 下载:
pip install -i https://pypi.douban.com/simple virtualenvwrapper-win
2.?环境变量里面配置
?3. 创建虚拟环境
mkvirtualenv -p /user/test/python.exe env_test1
|