我刚刚将我的 Mac 从 Snow Leopard 更新到 Lion。然后我需要安装 virtualenv
和 virtualenvwrapper
。 easy_install
我都用过。
我还将 virtualenvwrapper 设置添加到我的 .bash_profile 文件中,如下所示:
# virtualenvwrapper settings
export WORKON_HOME="~/virtualenvs"
source "/usr/local/bin/virtualenvwrapper.sh"
但是在采购它时我收到以下错误:
ERROR: Could not create temporary file name. Make sure TMPDIR is set.
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=/Library/Frameworks/Python.framework/Versions/2.7/bin/python and that PATH is set properly.
谢谢大家的帮助。
最佳答案
因为 /Library/Frameworks/Python.framework/Versions/2.7/bin/python
是单独安装的 Python 2.7(可能来自 python.org 安装程序)而不是 Apple - 提供 Python 2.7 (/usr/bin/python2.7
),您需要确保您正在为该单独的 Python 使用 easy_install
或更改为使用 Apple-提供的 Python。要执行任一操作,您应该确保您的 shell PATH 变量是正确的。对于第一种情况,您应该能够通过执行以下操作来安装 easy_install
:
cd /tmp
curl -O http://python-distribute.org/distribute_setup.py
sudo $VIRTUALENVWRAPPER_PYTHON distribute_setup.py
您可以修复您的 shell PATH 以包含框架 bin 目录。如果您使用 bash
,一种方法是将此行添加到 ~/.bash_profile
:
export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
然后打开一个新的终端 session 。您现在应该会发现刚刚安装的 easy_install
是正确的:
$ which easy_install
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install
关于python - Mac OS X Lion 上的 Virtualenvwrapper 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6933535/