Python 小牛升级后 virtualenvwrapper 的终端问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19549824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Terminal issue with virtualenvwrapper after Mavericks Upgrade
提问by Ryan Allen
After upgrading to OSX Mavericks, I am getting this message in the terminal:
升级到 OSX Mavericks 后,我在终端中收到此消息:
/usr/bin/python: 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 virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
采纳答案by Beau
Try reinstalling pip and then reinstalling virtualenvwrapper (I had to go through these steps after upgrading to Mavericks):
尝试重新安装 pip,然后重新安装 virtualenvwrapper(升级到 Mavericks 后我必须完成这些步骤):
$ sudo easy_install pip
$ sudo pip install --upgrade virtualenvwrapper
回答by metakermit
I wouldn't recommend running pip with sudo. Thiswas my solution for the same problem (after upgrading to Mavericks).
我不建议使用 sudo 运行 pip。这是我对同一问题的解决方案(升级到小牛队后)。
In essence, uninstall any virtualenv and brewed Python you had before (use which <command>
to check that you removed everything except the system Python in /usr/bin/python
) and cleanly install them once again:
本质上,卸载您之前拥有的任何 virtualenv 和 brewed Python(用于which <command>
检查您是否删除了除系统 Python 中的所有内容/usr/bin/python
)并再次干净地安装它们:
brew install python --with-brewed-openssl
# Open a new terminal tab now (to access /usr/local/bin/python)
pip install virtualenv
pip install virtualenvwrapper
回答by Josh Antweiler
Re-arrange the export order so that the python
path is placed before the virtualenv
commands in your .bash_profile
file.
重新安排导出顺序,以便将python
路径放置在文件中的virtualenv
命令之前.bash_profile
。
# python path
export PATH=/usr/local/bin:$PATH
# needed for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
回答by syodage
pip install --upgrade virtualenvwrapper
will fix the issue but never used sudo pip
this will change system-wide. If pip throws permission errors without sudo
then you should fix those and then try only with pip install <--upgrade> $(package)
.
pip install --upgrade virtualenvwrapper
将解决问题但从未使用过sudo pip
这将在系统范围内改变。如果 pip 在没有的情况下抛出权限错误,sudo
那么您应该修复这些错误,然后仅尝试使用pip install <--upgrade> $(package)
.
I rather suggest install homebrew
and then install pip
using brew install pip
which will install latest stable version of pip for you.
我宁愿建议先安装homebrew
,然后pip
使用brew install pip
它安装,这将为您安装最新的稳定版本的 pip。
Install homebrewand then run
brew doctor
. If there are any warnings fix those(actually brew will tell you how to fixed those).You may need to remove system-wide python comes with Mac and use
brew
to install required versions. Use thisto remove system-wide python- Use
brew install python
or/andbrew install python3
to install required python version/s. Finaly run
pip install --upgrade virtualenvwrapper
Now on never use
sudo pip
only usepip
.
回答by Tuan Pham
Try edit .bash_profile file
尝试编辑 .bash_profile 文件
# Home brew
export PATH=/usr/local/bin:$PATH
# virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
回答by neosergio
I had the same problem with MacOS High Sierra. I was able to fix it with these lines in my .bash_profile file:
我在 MacOS High Sierra 上遇到了同样的问题。我能够在我的 .bash_profile 文件中使用这些行修复它:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Code
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
回答by Nilisha Maheshwari
Running these two commands helped me get rid of it (had done a software update on macOS High Sierra)
运行这两个命令帮助我摆脱了它(在 macOS High Sierra 上做了软件更新)
$ sudo easy_install pip
$ sudo pip install --upgrade virtualenvwrapper
回答by PRIYANSHU SHARMA
You just need to configure the path properly. Run the following commands in the terminal:
您只需要正确配置路径。在终端中运行以下命令:
which python
which python
Output -
输出 -
/usr/bin/python
which virtualenvwrapper.sh
which virtualenvwrapper.sh
Output -
输出 -
/usr/local/bin/virtualenvwrapper.sh
echo $VIRTUALENVWRAPPER_PYTHON
/usr/local/bin/python
echo $VIRTUALENVWRAPPER_PYTHON
/usr/local/bin/python
So as you can see that the variable $VIRTUALENVWRAPPER_PYTHON
is pointing towards the wrong python path. So we need to reset the path of variable $VIRTUALENVWRAPPER_PYTHON
.
如您所见,该变量$VIRTUALENVWRAPPER_PYTHON
指向错误的 python 路径。所以我们需要重新设置变量的路径$VIRTUALENVWRAPPER_PYTHON
。
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
now run the following the command:
现在运行以下命令:
source /usr/local/bin/virtualenvwrapper.sh