问题描述
我已经使用自制软件在新的Mac Lion安装上安装了python,并且一直尝试通过pip安装virtualenv和virtualenvwrapper,但是当我启动一个新的终端会话时,我得到了以下回溯:
I've used homebrew to install python on a new Mac Lion installation, and have been trying to install virtualenv and virtualenvwrapper with pip, but when I start a new terminal session, I get this traceback:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader
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.
使用的python和pip来自自制软件,但似乎要我使用Apple的默认python.我得到以下内容
The python and pip used are from homebrew, but it seems to want me to use Apple's default python. I get the following
~$ which python | xargs ls -l
lrwxr-xr-x 1 beard admin 33 Jun 24 16:11 /usr/local/bin/python -> ../Cellar/python/2.7.3/bin/python
~$ echo $VIRTUALENVWRAPPER_PYTHON
/usr/local/bin/python
~$ which pip | xargs ls -l
-rwxr-xr-x 1 beard admin 301 Jun 24 16:18 /usr/local/share/python/pip
~$ which virtualenvwrapper.sh | xargs ls -l
-rwxr-xr-x 1 beard admin 32227 Jun 24 16:19 /usr/local/share/python/virtualenvwrapper.sh
但是,似乎认为我已经在/usr/bin/python
However, it seems to think that I've installed pip (and virtualenv) with the system python in /usr/bin/python
在我的bashrc中-
In my bashrc--
export WORKON_HOME="$HOME/py-env"
export VIRTUALENVWRAPPER_LOG_DIR="$HOME/py-env"
export VIRTUALENVWRAPPER_HOOK_DIR="$HOME/py-env"
source /usr/local/share/python/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON="/usr/local/bin/python"
推荐答案
由于您拥有自己的python版本,您是否尝试覆盖VIRTUALENVWRAPPER_PYTHON? (似乎您要export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
) virtualenvwrapper文档建议在采购virtualenvwrapper.sh之前将envvar设置为所需的python.他们的例子有:
Since you have your own version of python, have you tried overriding VIRTUALENVWRAPPER_PYTHON? (It looks like you want export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
) The virtualenvwrapper docs suggest setting that envvar to the desired python before sourcing virtualenvwrapper.sh. Their example has:
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
这篇关于OS X Lion上virtualenvwrapper的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!