8

我刚刚将我的 Mac 从 Snow Leopard 更新为 Lion。然后我需要安装virtualenvvirtualenvwrapper. 我两个都用过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.

感谢大家的帮助。

4

2 回答 2

13

由于是单独/Library/Frameworks/Python.framework/Versions/2.7/bin/python安装的 Python 2.7(可能来自 python.org 安装程序)而不是 Apple 提供的 Python 2.7 /usr/bin/python2.7easy_install- 提供 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}"

然后打开一个新的终端会话。您现在应该发现easy_install您刚刚安装的是正确的:

$ which easy_install
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install
于 2011-08-03T21:58:32.423 回答
0

我遇到了类似的问题,我通过将 $TMPDIR 导出到更合理的路径来解决它,而不是 Mac OS X 喜欢的随机垃圾。

$ grep TMPDIR ~/.env
export TMPDIR=/tmp/

$ source .env

现在virtualenvwrapper可以很好地创建其临时文件。长话短说,只需添加export TMP=/tmp/whatever到您的 shell 运行时配置文件中(例如,对于 ZSH 它是~/.zsh,对于 bash 它是~/.bashrc)。

于 2011-08-04T11:15:45.277 回答