错误:环境/Users/myuser/.virtualenvs/iron 不包含激活脚本 [英] Error: Environment /Users/myuser/.virtualenvs/iron does not contain activation script
问题描述
我在 macOS Catalina 版本 10.15.1 上运行 python 3.7.6,我正在尝试安装和设置 virtualenvwrapper
,我已经安装了 pip3 install virtualenvwrapper
.
I am running python 3.7.6 on macOS Catalina version 10.15.1 and I am trying to install and set up virtualenvwrapper
which I have installed with pip3 install virtualenvwrapper
.
我的 .bash_profile 中有以下几行:
I have the following lines in my .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.以及其他教程(像这个)
These are configuration steps I have followed from: https://stackoverflow.com/a/42643313/5420796. As well as other tutorials (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
So you can see I'm attemping to point these export variables to the right place, in my terminal, the output of which python3
is /usr/local/bin/python3
The output of which virtualenv
is: /Users/maxcarey/Library/Python/3.7/bin/virtualenv.
The output of which virtualenvwrapper.sh
is /Users/maxcarey/Library/Python/3.7/bin/virtualenvwrapper.sh
这里有问题:当我运行:mkvirtualenv iron
来创建一个新的虚拟环境(在这种情况下称为铁),命令的输出是:
Here is the problem: when I run: mkvirtualenv iron
to create a new virtual environment (called iron in this case), the output of the command is:
用播种机在 193ms CPython3Posix(dest=/Users/maxcarey/.virtualenvs/iron, clear=False, global=False) 中创建虚拟环境 FromAppData pip=latest setuptools=latest wheel=latest app_data_dir=/Users/maxcarey/Library/Application Support/virtualenv/seed-v1 via=copyvirtualenvwrapper.user_scripts 创建/Users/maxcarey/.virtualenvs/iron/bin/predeactivate错误:环境/Users/maxcarey/.virtualenvs/iron"不包含激活脚本.
created virtual environment in 193ms CPython3Posix(dest=/Users/maxcarey/.virtualenvs/iron, clear=False, global=False) with seeder FromAppData pip=latest setuptools=latest wheel=latest app_data_dir=/Users/maxcarey/Library/Application Support/virtualenv/seed-v1 via=copy virtualenvwrapper.user_scripts creating /Users/maxcarey/.virtualenvs/iron/bin/predeactivate ERROR: Environment '/Users/maxcarey/.virtualenvs/iron' does not contain an activate script.
您可以看到确实创建了一个虚拟环境,但是,我收到一条错误消息,说没有激活脚本.但是,当我导航到 ~/.virtualenvs
时,确实可以看到激活脚本.这是新文件夹 iron/local/
中 tree
的输出:
You can see that a virtual environment is indeed created, however, I get an error saying there is no activation script. However, when I navigate to ~/.virtualenvs
, I can indeed see the activation scripts. Here is the output of tree
inside the new folder 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
简单地破坏和重新创建虚拟环境,但是,当再次创建环境时,我仍然遇到相同的错误.谢谢
It does indeed appear that there are activation scripts. So I am stumped about why I get the activation script error (which I also get when running workon iron
). I have tried simply destroying and recreating the virtual environment with rmvirtualenv iron
, which works, however, when creating the environment again I still get the same error. Thank You
推荐答案
我的解决方案是将 export VIRTUALENVWRAPPER_ENV_BIN_DIR=usr/local/bin
添加到我的 shell 启动文件 之后virtualenvwrapper.sh
脚本被调用.
My solution was to add export VIRTUALENVWRAPPER_ENV_BIN_DIR=usr/local/bin
to my shell startup file after the virtualenvwrapper.sh
script gets called.
在查看源代码并看到它在 usr/local/bin
中创建 activate
脚本后,我找到了这个修复程序,但是 virtualenvwrapper.sh
脚本出于某种原因只在 bin
中查找.
I figured out this fix after looking at the source and seeing that it was creating the activate
script in usr/local/bin
, but the virtualenvwrapper.sh
script was looking in just bin
for some reason.
我的完整 shell 启动配置现在是这样的:
My full shell startup config is now this:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_ENV_BIN_DIR=usr/local/bin
这篇关于错误:环境/Users/myuser/.virtualenvs/iron 不包含激活脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!