最佳答案
I'm running Mac OS 10.6.8. and wanted to install in addition to python 2.6 also python 2.7 and use python 2.7 in a new virtualenv. I executed the following steps:
I downloaded python 2.7 and installed it:
http://www.python.org/ftp/python/2.7.3/python-2.7.3-macosx10.6.dmg
Then I run the command to setup a new virtualenv using python2.7:
mkvirtualenv --python=python2.7 mynewenv
My .bash_profile looks like the following:
# needed for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
Now when I open the console I get the following error message.
ImportError: No module named virtualenvwrapper.hook_loader
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=/usr/local/bin/python and that PATH is set properly.
I also found in a different post that I should upgrade virtualenvwrapper. That did not help.
sudo pip install virtualenvwrapper --upgrade
Any help would be appreciated.