Mac OS X Lion 上的 Virtualenvwrapper 错误

发布于 2024-11-27 22:22:38 字数 772 浏览 2 评论 0原文

我刚刚将我的 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.

谢谢大家的帮助。

I have just update my Mac from Snow Leopard to Lion. I then needed to install virtualenv and virtualenvwrapper. I used for both easy_install.
I also added virtualenvwrapper settings to my .bash_profile file as following:

# virtualenvwrapper settings
export WORKON_HOME="~/virtualenvs"
source "/usr/local/bin/virtualenvwrapper.sh"

But when sourcing it I get the following error:

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.

Thank you all for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

城歌 2024-12-04 22:22:38

由于 /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}"

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

$ which easy_install
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install

Since /Library/Frameworks/Python.framework/Versions/2.7/bin/python is the path to a separately-installed Python 2.7 (possibly from a python.org installer) rather than the Apple-supplied Python 2.7 (/usr/bin/python2.7), you need to make sure you are using an easy_install for that separate Python or change to using the Apple-supplied Python. To do either one, you should ensure that your shell PATH variable is correct. For the first case, you should be able to install an easy_install by doing the following:

cd /tmp
curl -O http://python-distribute.org/distribute_setup.py
sudo $VIRTUALENVWRAPPER_PYTHON distribute_setup.py

You can fix up your shell PATH to include the framework bin directory. If you are using bash, one way would be to add this line to ~/.bash_profile:

export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

Then open a new Terminal session. You should now find that easy_install you just installed is the right one:

$ which easy_install
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install
聽兲甴掵 2024-12-04 22:22:38

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

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

$ source .env

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

I had a similar problem and I solved it by exporting $TMPDIR to a saner path, rather than the random crap that Mac OS X prefers.

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

$ source .env

and now virtualenvwrapper can create its temporary files fine. To make the long story short, just add export TMP=/tmp/whatever to your shell runtime configuration file (for example, for ZSH it is ~/.zsh, for bash it is ~/.bashrc).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文