[英]Python could not import the module virtualenvwrapper.hook_loader?
If Python could not import the module virtualenvwrapper.hook_loader, and I get this message如果 Python 无法导入模块 virtualenvwrapper.hook_loader,我会收到此消息
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is
set properly.
How do I start to set it up in Debian 9?如何开始在 Debian 9 中进行设置?
Installing virtualenv by both, pip
and pip3
doesn't make any sense because installing it by any one shows virutalenvwrapper in both, pip list
and pip3 list
.通过
pip
和pip3
安装 virtualenv 没有任何意义,因为任何人安装它都会在pip list
和pip3 list
中显示 virutalenvwrapper 。
The right way is to copy the following code in your ~/.bashrc
.正确的方法是将以下代码复制到您的
~/.bashrc
中。
VIRTUALENVWRAPPER_PYTHON=$(which python3)
VIRTUALENVWRAPPER_PYTHON=$(哪个python3)
NOTE: Use the python version you want to use, in my case it's python3
.注意:使用您要使用的 python 版本,在我的例子中是
python3
。
You have to install virtualenvwrapper separately for different versions of Python:您必须为不同版本的 Python 分别安装 virtualenvwrapper:
pip install virtualenvwrapper
pip3 install virtualenvwrapper
The first one is for Python 2.7, the second for Python 3.第一个用于 Python 2.7,第二个用于 Python 3。
对于 MacOS,您需要将 VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 更改为 VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
This have solved my issue on macOS Monterey 2022:这解决了我在 macOS Monterey 2022 上的问题:
Terminal终端
cd
nano .bashrc
Code in file文件中的代码
export WORKON_HOME=~/.virtualenvs
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
save it保存
CTRL + x
y
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.