1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

14 Comments

Thanks for your reply. But now I get the following error -bash: /usr/local/bin/virtualenvwrapper.sh: line 127: syntax error near unexpected token ``os.path.normpath'` -bash: /usr/local/bin/virtualenvwrapper.sh: line 127: "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')"'
You have a typo! copy and paste line 127 of the file here
I don't think I have a typo. Even replacing the if/else with just VIRTUALENVWRAPPER_PYTHON="$(command \which python)" still gives the old initalization of hooks error. :-/
do you use python3.5?
Awesome! Thank you so much! You are a star! :)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.