【发布时间】:2020-05-31 18:36:55
【问题描述】:
我在 macOS Catalina 版本 10.15.1 上运行 python 3.7.6,我正在尝试安装和设置 virtualenvwrapper,我已使用 pip3 install virtualenvwrapper 安装。
我的 .bash_profile 中有以下几行:
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/Users/maxcarey/Library/Python/3.7/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
source /Users/maxcarey/Library/Python/3.7/bin/virtualenvwrapper.sh
这些是我遵循的配置步骤: https://stackoverflow.com/a/42643313/5420796。以及其他教程(like this one)
所以你可以看到我正在尝试将这些导出变量指向正确的位置,在我的终端中,which python3 的输出是/usr/local/bin/python3
which virtualenv 的输出是:/Users/maxcarey/Library/Python/3.7/bin/virtualenv。
which virtualenvwrapper.sh 的输出是/Users/maxcarey/Library/Python/3.7/bin/virtualenvwrapper.sh
问题出在这里:当我运行:mkvirtualenv iron 来创建一个新的虚拟环境(在本例中称为 Iron)时,命令的输出是:
在 193 毫秒 CPython3Posix(dest=/Users/maxcarey/.virtualenvs/iron, clear=False, global=False) 中使用播种机 FromAppData pip=latest setuptools=latest wheel=latest app_data_dir=/Users/maxcarey/Library 创建虚拟环境/应用程序支持/virtualenv/seed-v1 via=copy virtualenvwrapper.user_scripts 创建 /Users/maxcarey/.virtualenvs/iron/bin/predeactivate 错误:环境“/Users/maxcarey/.virtualenvs/iron”不包含激活脚本。
您可以看到确实创建了一个虚拟环境,但是,我收到一条错误消息,说没有激活脚本。但是,当我导航到~/.virtualenvs 时,我确实可以看到激活脚本。这是tree 在新文件夹iron/local/ 中的输出:
└── local
└── bin
├── activate
├── activate.csh
├── activate.fish
├── activate.ps1
├── activate.xsh
├── activate_this.py
├── easy_install
├── easy_install-3.7
├── easy_install3
├── pip
├── pip-3.7
├── pip3
├── python -> /Library/Developer/CommandLineTools/usr/bin/python3
├── python3 -> python
├── python3.7 -> python
├── wheel
├── wheel-3.7
└── wheel3
确实似乎有激活脚本。所以我很困惑为什么我会收到激活脚本错误(我在运行workon iron 时也会遇到这个错误)。我尝试过使用rmvirtualenv iron 简单地破坏和重新创建虚拟环境,但是,当再次创建环境时,我仍然遇到相同的错误。谢谢你
【问题讨论】:
标签: python-3.x virtualenv virtualenvwrapper