我正在 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 https://stackoverflow.com/a/42643313/5420796。以及其他教程(像这个 https://realpython.com/python-virtual-environments-a-primer/)
所以你可以看到我正在尝试将这些导出变量指向正确的位置,在我的终端中,输出为which python3
is /usr/local/bin/python3
的输出which virtualenv
是:/Users/maxcarey/Library/Python/3.7/bin/virtualenv。
的输出which virtualenvwrapper.sh
is /Users/maxcarey/Library/Python/3.7/bin/virtualenvwrapper.sh
问题是:当我运行时:mkvirtualenv iron
要创建一个新的虚拟环境(在本例中称为iron),命令的输出为:
使用播种器 FromAppData pip=latest setuptools=latest wheel=latest app_data_dir=/Users/maxcarey/Library/Application Support 在 193ms 内创建虚拟环境 CPython3Posix(dest=/Users/maxcarey/.virtualenvs/iron, clear=False, global=False) /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
,它有效,但是,再次创建环境时我仍然遇到相同的错误。谢谢