Mac OS X Lion 上的 Virtualenvwrapper 错误
我刚刚将我的 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.
谢谢大家的帮助。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于
/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
:您可以修复 shell PATH 以包含框架 bin 目录。如果您使用的是
bash
,一种方法是将此行添加到~/.bash_profile
:然后打开一个新的终端会话。您现在应该发现刚刚安装的
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 aneasy_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 aneasy_install
by doing the following: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
:Then open a new Terminal session. You should now find that
easy_install
you just installed is the right one:我遇到了类似的问题,我通过将 $TMPDIR 导出到更合理的路径来解决它,而不是 Mac OS X 喜欢的随机垃圾。
现在 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.
and now
virtualenvwrapper
can create its temporary files fine. To make the long story short, just addexport TMP=/tmp/whatever
to your shell runtime configuration file (for example, for ZSH it is~/.zsh
, for bash it is~/.bashrc
).