user20112015
user20112015

Reputation: 307

Problems when installing virtualenvwrapper in macOS

I need to install virtualenvwrapper on my macOS Sierra to be able to install TensorFlow. Previously I had installed Python 3 based on the instructions here using Homebrew.

Now pip seemed to be nonexistent (pip2 and pip3 worked though), so I did

sudo easy_install pip

Then I followed the instructions given here, and when I do

source /usr/local/bin/virtualenvwrapper.sh

I get the following error:

No module named virtualenvwrapper virtualenvwrapper.sh:
There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.

I have tried the solutions given here, and here, but no success. I have even tried to install virtualenvwrapper with:

sudo pip2 install --upgrade virtualenvwrapper

and

sudo pip3 install --upgrade virtualenvwrapper

and still I get the same error. Could someone please help me with this issue?

EDIT:

I have tried to do lazy loading of the virtualenvwrapper like so:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh

Only then I don't get any errors, and I am able to proceed with installing TensorFlow. But then every time I open a new terminal workon does not work, and I have to do source /usr/local/bin/virtualenvwrapper_lazy.sh every time to be able to use workon. Even when workon is invoked I get a warning/error message as /usr/bin/python: No module named virtualenvwrapper.

Could someone help me see what is going on here?

Upvotes: 1

Views: 661

Answers (1)

Amin Etesamian
Amin Etesamian

Reputation: 3699

My solution is simply a hack and not a clean and logical way for solving this but you could edit /usr/local/bin/virtualenvwrapper.sh as root and in the section that is followed by

# Locate the global Python where virtualenvwrapper is installed.

remove the if/else condition and simply use VIRTUALENVWRAPPER_PYTHON="$(command \which python3.5)" (Change 3.5 to your version) and then source the file again.

Upvotes: 2

Related Questions