11

I get this error when I boot up terminal:

Last login: Thu Apr 9 19:49:08 on ttys001
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/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=/Library/Frameworks/Python.framework/Versions/2.7/bin/python and that PATH is
set properly.
dhcp-128-189-78-23:~ user_me$ 

I need to "point" my virtual environment to the version of python I'm using.

How can I do this?

asked Apr 10, 2015 at 2:55

4 Answers 4

28

The following was found in the virtualenvwrapper install guide. You could try this to set up your $PATH correct.

To override the $PATH search, set the variable VIRTUALENVWRAPPER_PYTHON to the full path of the interpreter to use and VIRTUALENVWRAPPER_VIRTUALENV to the full path of the virtualenv binary to use. Both variables must be set before sourcing virtualenvwrapper.sh. For example:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
answered Apr 10, 2015 at 7:51
Sign up to request clarification or add additional context in comments.

2 Comments

Once I removed local it's working fine in Ubuntu 20. Just update your comment. "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python"
This should've been the accepted answer as this does not require uninstalling any system packages.
16

I had the same exact issue and updating my path didn't help anything, nor did setting VIRTUALENVWRAPPER_PYTHON and VIRTUALENVWRAPPER_VIRTUALENV. This is because I was seeing this strange behavior when running my version of python:

$ /usr/local/bin/python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.executable
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

I was able to fix everything by uninstalling python with brew, reinstalling python with brew, and forcing it to overwrite existing symlinks in /usr/local/bin.

brew uninstall --force python
brew install python
brew link --overwrite python
brew linkapps python
pip install --upgrade pip setuptools
sudo pip uninstall virtualenv
pip install virtualenv
sudo pip uninstall virtualenvwrapper
pip install virtualenvwrapper

Hopefully you were able to get past this issue when you encountered it six months ago. I wanted to post my solution in case others run in to the same issue and cannot solve it by setting their paths and env variables.

Mr_Spock
3,8356 gold badges28 silver badges34 bronze badges
answered Nov 4, 2015 at 22:04

Comments

2

I used to use brew install multi version python, but i use the native python created virtualenv, as i've updated my mac os version, something wrong happened. I can not get my virtualenv work with below error.

/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named virtualenvwrapper

Things i've done make my environment back.

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python get-pip.py
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -m pip install virtualenvwrapper
answered Mar 25, 2021 at 14:35

Comments

0

Today I got this error after a series of steps, the first was to install wormhole (https://magic-wormhole.readthedocs.io/en/latest/welcome.html#example) which installed Python 3.8. I started having other errors which I resolved doing a brew uninstall python@2

brew uninstall python@2
Uninstalling /usr/local/Cellar/python@2/2.7.15_2... (4,814 files, 84.8MB)
python@2 HEAD_3 is still installed.
Run `brew uninstall --force python@2` to remove all versions.
brew uninstall --force python@2
Uninstalling python@2... (822B)

At this point the error in this question appeared:

Last login: Wed May 27 11:33:08 on ttys025
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/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.

My solution was to :

ls -l /usr/local/bin/python3
lrwxr-xr-x 1 neo admin 34 Nov 27 16:46 /usr/local/bin/python3 -> ../Cellar/python/3.7.5/bin/python3
ln -s ../Cellar/python/3.7.5/bin/python3 /usr/local/bin/python

Now the error seems to be gone. I am not sure if this is a good solution, I am interested in the feedback of those people who understand/know brew better than me.

answered May 27, 2020 at 9:41

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.