[英]Problems when installing virtualenvwrapper in macOS
I need to install virtualenvwrapper
on my macOS Sierra to be able to install TensorFlow . 我需要在macOS Sierra上安装
virtualenvwrapper
才能安装TensorFlow 。 Previously I had installed Python 3 based on the instructions here using Homebrew
. 以前,我已根据此处使用
Homebrew
的说明安装了Python 3。
Now pip
seemed to be nonexistent ( pip2
and pip3
worked though), so I did 现在
pip
似乎不存在(尽管pip2
和pip3
起作用了),所以我做了
sudo easy_install pip
Then I followed the instructions given here , and when I do 然后我按照这里给出的说明进行操作
source /usr/local/bin/virtualenvwrapper.sh
I get the following error: 我收到以下错误:
No module named virtualenvwrapper virtualenvwrapper.sh:
There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
I have tried the solutions given here , and here , but no success. 我尝试了此处和此处给出的解决方案,但没有成功。 I have even tried to install
virtualenvwrapper
with: 我什至尝试使用以下命令安装
virtualenvwrapper
:
sudo pip2 install --upgrade virtualenvwrapper
and 和
sudo pip3 install --upgrade virtualenvwrapper
and still I get the same error. 仍然出现相同的错误。 Could someone please help me with this issue?
有人可以帮我解决这个问题吗?
EDIT: 编辑:
I have tried to do lazy loading of the virtualenvwrapper
like so: 我已经尝试过像下面这样延迟加载
virtualenvwrapper
:
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh
Only then I don't get any errors, and I am able to proceed with installing TensorFlow
. 只有这样,我才不会出现任何错误,并且能够继续安装
TensorFlow
。 But then every time I open a new terminal workon
does not work, and I have to do source /usr/local/bin/virtualenvwrapper_lazy.sh
every time to be able to use workon
. 但是然后每次我打开一个新的终端
workon
都行不通,并且每次必须使用source /usr/local/bin/virtualenvwrapper_lazy.sh
才能使用workon
。 Even when workon
is invoked I get a warning/error message as /usr/bin/python: No module named virtualenvwrapper
. 即使调用
workon
,我workon
收到/usr/bin/python: No module named virtualenvwrapper
的警告/错误消息/usr/bin/python: No module named virtualenvwrapper
。
Could someone help me see what is going on here? 有人可以帮我看看这是怎么回事吗?
My solution is simply a hack and not a clean and logical way for solving this but you could edit /usr/local/bin/virtualenvwrapper.sh
as root and in the section that is followed by 我的解决方案只是一种破解方法,而不是一种解决问题的干净而合乎逻辑的方法,但是您可以以root身份在
/usr/local/bin/virtualenvwrapper.sh
并在其后的部分中进行编辑。
# Locate the global Python where virtualenvwrapper is installed.
remove the if/else condition and simply use VIRTUALENVWRAPPER_PYTHON="$(command \\which python3.5)"
(Change 3.5 to your version) and then source
the file again. 删除if / else条件和简单的使用
VIRTUALENVWRAPPER_PYTHON="$(command \\which python3.5)"
(更改3.5到您的版本),然后source
再次文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.