我在终端上开始新会话时遇到问题:
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.
所以我按照Error message for virtualenvwrapper on OS X Lion上的说明进行操作。
现在错误是:
-bash: /usr/local/share/python/virtualenvwrapper.sh: No such file or directory
不确定如何解决这个问题。
需要一些指导..
编辑:
Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
答案 0 :(得分:1)
尝试将这些行添加到您的shell启动文件(.bashrc
,.profile
..)中:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
之后输入source .bashrc
或source .profile
,具体取决于您的启动文件,您应该没问题。
答案 1 :(得分:1)
如果您正在使用或安装适用于Python3的virtualenv,请确保您在Python3
目录中有/usr/local/bin
文件。然后,您可以在virtualenv包装器配置下的.bashrc或.zshrc(for zsh)文件中使用以下行。
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
否则,如果您正在安装python 2.7,那么Python文件通常位于/usr/bin/
目录中,因此您可以将.bashrc中的VIRTUALENVWRAPPER_PYTHON
或.zshrc(对于zsh)更新为:
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
注意:安装python3时请记得使用pip3 install virtualenvwrapper
答案 2 :(得分:0)
您需要确保路径正确。在我的机器上,脚本位于此处:
source /usr/local/bin/virtualenvwrapper.sh