mac使用python的virtualenvwrapper创建虚拟环境
时间: 2023-10-14 14:27:06 浏览: 146
该怎么操作?
首先,你需要确保已经在你的 Mac 上安装了 Python。然后,你可以通过 pip 安装 virtualenvwrapper:
```
pip install virtualenvwrapper
```
安装完成后,请在你的 shell 配置文件(如:`~/.bashrc` 或 `~/.zshrc`)中添加以下内容:
```
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python # 这里需要设置为你的 Python 版本路径
export WORKON_HOME=~/.virtualenvs # 虚拟环境的安装目录
source /usr/local/bin/virtualenvwrapper.sh # virtualenvwrapper 的安装路径
```
完成配置后,请保存并执行以下命令来使其生效:
```
source ~/.zshrc # 如果你使用的是 zsh
source ~/.bashrc # 如果你使用的是 bash
```
接着,你可以通过以下命令来创建虚拟环境:
```
mkvirtualenv myenv
```
其中 `myenv` 是你想要创建的虚拟环境的名称。创建完成后,你可以通过以下命令来激活它:
```
workon myenv
```
现在,你就可以在这个虚拟环境中安装你需要的库了。如果你不再需要使用这个虚拟环境,你可以通过以下命令来退出它:
```
deactivate
```
希望这能回答你的问题。
阅读全文
相关推荐

















