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.
I had this problem after uninstalling the
virtualenvwrapper
package. When I logged in to any user (orsu
to a different one), I would get:The solution was to delete the/etc/bash_completion.d/virtualenvwrapper
file.Edit:
Do not delete the above file or it won't be recreated if you reinstall
virtualenvwrapper
. Instead what you need to do ispurge
thevirtualenvwrapper
package when you uninstall it. Like this on Debian:There are a number of things that can cause this error. If your environment is
python3
installed fromepel-release
pip3
installed withpython3.4 get-pip.py
virtualenvwrapper
installed withpip3
mkvirtualenv -p /usr/bin/python3.4
Then, for whatever reason, the virtual environment is created without the virtualenvwrapper library. You can solve it by simply installing it again, but this time from within the virtlualenv
In my situation (OS X 10.13.6), this did it
For anyone using Ubuntu 18.04 and Python 3+, this did the trick for me:
Even though there is an accepted answer I thought I would put what fixed it for me.
Firstly I installed Python and had just upgraded it via Homebrew. I am also using ZSH so if some bits don't quite match your output then that might be why.
By running brew info python and looking through the output I found the following nice bit of information:
So I added this to my terminal startup script as shown and the error n longer displays.
Note: I inserted this into another part of my PATH and the error persisted on start up.
Ran into a similar issue after installing Conda/Anaconda project. This question was quite helpful in resolving my issue on MAC.Resolving the issue had my
.zshrc
relevant portion looking like this:This is depended on where I have conda installed and you'll have to figure that in your own case. To get the specifics for your given environment depending on where you've installed anaconda you can use the following:
DON'T FORGET TO UNINSTALL AND INSTALL virtualenv and virtualenvwrapper as highlighted in other answers.