Terminal issue with virtualenvwrapper after Mavericks Upgrade
Asked Answered
B

9

44

After upgrading to OSX Mavericks, I am getting this message in 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 virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
Broadminded answered 23/10, 2013 at 18:42 Comment(1)
Are you sure that virtualenvwrapper.sh is supposed to be in /usr/bin/python or have you installed it into a different version of Python (e.g. installed with Homebrew?)Shimmer
S
101

Try reinstalling pip and then reinstalling virtualenvwrapper (I had to go through these steps after upgrading to Mavericks):

$ sudo easy_install pip
$ sudo pip install --upgrade virtualenvwrapper
Supernumerary answered 23/10, 2013 at 19:18 Comment(2)
Yup, I reinstalled pip and upgraded with the python scripts, then used your advice to upgrade virtualenvwrapper. All is well now, much thanks.Broadminded
this worked for me, but only after re-installing easy_install as per this postHautboy
I
11

Re-arrange the export order so that the python path is placed before the virtualenv commands in your .bash_profile file.

# python path
export PATH=/usr/local/bin:$PATH

# needed for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
Islas answered 12/10, 2014 at 3:28 Comment(1)
And don't source virtualenvwrapper.sh from .bashrc - that is called early in .bash_profile.Tympanist
D
6

Try edit .bash_profile file

# Home brew
export PATH=/usr/local/bin:$PATH

# 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
Duckpin answered 7/3, 2017 at 8:16 Comment(1)
The only one that worked for me on macOS High Sierra. Thanks @TuanHiltner
T
4

I wouldn't recommend running pip with sudo. This was my solution for the same problem (after upgrading to Mavericks).

In essence, uninstall any virtualenv and brewed Python you had before (use which <command> to check that you removed everything except the system Python in /usr/bin/python) and cleanly install them once again:

brew install python --with-brewed-openssl
# Open a new terminal tab now (to access /usr/local/bin/python)
pip install virtualenv
pip install virtualenvwrapper
Tunicate answered 3/11, 2013 at 17:48 Comment(0)
M
1

pip install --upgrade virtualenvwrapper will fix the issue but never used sudo pip this will change system-wide. If pip throws permission errors without sudo then you should fix those and then try only with pip install <--upgrade> $(package).

I rather suggest install homebrew and then install pip using brew install pip which will install latest stable version of pip for you.

  1. Install homebrew and then run brew doctor . If there are any warnings fix those(actually brew will tell you how to fixed those).

  2. You may need to remove system-wide python comes with Mac and use brew to install required versions. Use this to remove system-wide python

  3. Use brew install python or/and brew install python3 to install required python version/s.
  4. Finaly run pip install --upgrade virtualenvwrapper

  5. Now on never use sudo pip only use pip.

Murky answered 1/9, 2016 at 22:30 Comment(0)
D
1

I had the same problem with MacOS High Sierra. I was able to fix it with these lines in my .bash_profile file:

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Code
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
Durwyn answered 13/4, 2018 at 18:30 Comment(2)
What is Code?Lancelle
@chrisFrisina Code is a directory inside my /home, you can change it and name as you want to, after creating the directoryDurwyn
C
1

You just need to configure the path properly. Run the following commands in the terminal:

  1. which python

Output -

/usr/bin/python
  1. which virtualenvwrapper.sh

Output -

/usr/local/bin/virtualenvwrapper.sh
  1. echo $VIRTUALENVWRAPPER_PYTHON

    /usr/local/bin/python

So as you can see that the variable $VIRTUALENVWRAPPER_PYTHON is pointing towards the wrong python path. So we need to reset the path of variable $VIRTUALENVWRAPPER_PYTHON.

  1. export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python

now run the following the command:

source /usr/local/bin/virtualenvwrapper.sh 
Conservative answered 22/5, 2019 at 10:33 Comment(2)
I have the same problem but in the step 3 when I run echo $VIRTUALENVWRAPPER_PYTHON I get usr/bin/python3 <br/> Because in the step 1 I have **usr/bin/pythonDebera
Step-3 here was super helpful for me because all along I was pointing to the wrong python path. Once I got that path right, it cleared the issue. Thanks again.Libb
W
0

Running these two commands helped me get rid of it (had done a software update on macOS High Sierra)

$ sudo easy_install pip

$ sudo pip install --upgrade virtualenvwrapper
Warison answered 16/4, 2018 at 4:7 Comment(0)
U
0

Firstly Cross-verify PATH in .bashrc with following commands:

which virtualenv
which virtualenvwrapper.sh

output of:

echo $VIRTUALENVWRAPPER_PYTHON

and

which python3

should be same which is

/usr/bin/python3

Configure the path accordingly to above results

export WORKON_HOME=~/.virtualenvs

export MY_PROJECT=~/my_proj

export VIRTUALENVWRAPPER_WORKON_CD=1

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

export VIRTUALENVWRAPPER_VIRTUALENV='result of which virtualenv'

source 'result of which virtualenvwrapper.sh'

if after verifying path still INITIALIZATION HOOK ERROR REMAINS.

Then, In source left everthing as it is just replace virtualenvwrapper.sh with virtualenvwrapper_lazy.sh

Then it should work

Unveiling answered 22/9, 2021 at 18:47 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Ufa

© 2022 - 2024 — McMap. All rights reserved.