0

I upgraded brew and now I'm getting this message every time I open the terminal:

/usr/bin/python: 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 tried the suggested solutions posted by Railslide and Sudipta Basak from the following post, but neither are fixing this issue for me: problems with python and virtualenvwrapper after updating: No module named virtualenvwrapper

Executing "/usr/local/bin/pip3 install virtualenv virtualenvwrapper" gives me the "Requirement already satisfied" message.

I'm on Mac, and this is breaking a few things for me, like Juypter Notebook that I had installed with Anaconda, so any help would be appreciated!

Greeen
  • 33
  • 4
  • What version of Python are you actually running in your default shell? – Makoto Jan 06 '20 at 17:49
  • @Makoto Version 2.7.10 – Greeen Jan 06 '20 at 17:53
  • What does `echo $PATH` give you and what order is your Python executables (e.g. does Python 2 come before Python 3)? – Makoto Jan 06 '20 at 17:56
  • Running `echo $PATH` is giving me `usr/bin/sudo:/Users/_myName_/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`. This may be a silly question, but how do I check the order of my Python executables? Looking in /usr/bin/, I am seeing `python`. Looking in /usr/local/bin/, I see `python3` as Alias. – Greeen Jan 06 '20 at 18:03
  • If Python 2 is in `/usr/bin` and Python 3 is in `/usr/local/bin`, then `/usr/local/bin` needs to come before `/usr/bin` in your `PATH`. Seeing Python 3 as an *alias* (and aliases have very explicit meanings in \*nix) could be problematic. – Makoto Jan 06 '20 at 18:19
  • Do you think that's the reason why I'm getting this error message for virtualenvwrapper? Any recommendations on the steps I should take next? – Greeen Jan 06 '20 at 18:32
  • It's been a moment since I've dealt with brew installations, but I would imagine that you want your brew path to be the first thing on your `PATH` as opposed to `/usr/bin/sudo`. That'd be about the only thing I could think of from here. – Makoto Jan 06 '20 at 18:34
  • @Makoto Thanks. I'll give that a try. – Greeen Jan 06 '20 at 19:20

1 Answers1

0

You have to install virtualenvwrapper for the instance of pip that goes along with the instance of python that you are using.

For example, my ~/.zprofile contains these setup commands:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/opt/homebrew/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/opt/homebrew/bin/virtualenv
source /opt/homebrew/bin/virtualenvwrapper.sh

Because I am using /opt/homebrew/bin/python3, I need to use the corresponding version of pip:

/opt/homebrew/bin/pip3 install virtualenvwrapper
Brendan Quinn
  • 2,059
  • 1
  • 19
  • 22