Virtualenvwrapper errors on Mac OS X Lion
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 se开发者_JAVA百科ttings
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.
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
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
).
精彩评论