1

I am facing issues when I start new session on terminal:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
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/bin/python and that PATH is
set properly.

So I followed the instructions on the Error message for virtualenvwrapper on OS X Lion.

Now the error is:

-bash: /usr/local/share/python/virtualenvwrapper.sh: No such file or directory

Not sure how to solve this..

Need some guidance..

Edit:

 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

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8    
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
2
  • Are you using Python installed by brew, or the python.org installer? Chances are you have multiple Python installations and the wrapper script is installed on an alternate (non-default) Python. Commented Aug 31, 2014 at 8:40
  • how to remove the multiple python installations?
    – lakshmen
    Commented Aug 31, 2014 at 8:45

3 Answers 3

1

Try to add these lines to your shell startup file (.bashrc, .profile..):

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

After that type source .bashrc or source .profile depending on your startup file, and you should be fine.

1
  • the old error comes out.. Will paste what is inside bash_profile in the question..
    – lakshmen
    Commented Aug 31, 2014 at 8:36
1

If you are using or installing virtualenv for Python3, Ensure u have the Python3 file in /usr/local/bin directory. Then you can use the line below in your .bashrc or .zshrc(for zsh) file under the virtualenv wrapper configurations.

VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3

Otherwise if you are installing for python 2.7 normally the Python file is in the /usr/bin/ directory so you can update your VIRTUALENVWRAPPER_PYTHON in the .bashrc or .zshrc(for zsh) to be:

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python

NB: Remember to use pip3 install virtualenvwrapper when installing for python3

0

You need to ensure the paths are correct. On my machine that script is located here:

source /usr/local/bin/virtualenvwrapper.sh

Not the answer you're looking for? Browse other questions tagged or ask your own question.