problems with python and virtualenvwrapper after updating: No module named virtualenvwrapper
Asked Answered
A

3

24

I run python 2.7.6 with virtualenv, virtualenvwrapper under ubuntu 14.04. now i have installed python 2.7.9 from source. the new python interpreter is now located under /usr/local/bin but it seems the old interpreter is also located under /usr/bin.

if I run python shell it shows up python2.7.9. but if I use mkvirtualenv venv I am getting the following message.

New python executable in venv/bin/python
Installing setuptools, pip...done.
Blockquote /usr/local/bin/python: No module named virtualenvwrapper

old .bashrc (with working configuration using python 2.7.6 interpreter)

# virtualenv-wrappper path
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh

new .bashrc (with failure configuration)

# virtualenv-wrappper path
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

with the new .baschrc I type in source .bashrc and get the following output.

/usr/local/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/local/bin/python and that PATH is set properly.

And I have also tried which -a python:

output:

/usr/local/bin/python
/usr/bin/python

I want to use python 2.7.9 with virtualenv and virtualenvwrapper. so what I have to do to get this running ?

Astrogeology answered 7/4, 2015 at 7:26 Comment(6)
Have you installed virtualenvwrapper under python 2.7.9?Shanklin
yes i have reinstalled both virtualenv and virtualenvwrapper under python2.7.9. give me the same results.Astrogeology
if you try to import virtualenvwrapper from python (2.7.9) shell, do you get any error? And what if you try to create the virtualenv with -p path/to/python/interpreter?Shanklin
@Railslide: tried to import it from python shell as you said give me an error. ImportError: No module named virtualenvwrapper. same with virtualenv.Astrogeology
How did you install virtualenv and virtualenvwrapper?Shanklin
sudo pip install virtualenv virtualenvwrapperAstrogeology
S
20

You need to install them under python 2.7.9 by specifying the path to correct version of pip to be used

/usr/local/bin/pip install virtualenv virtualenvwrapper

otherwise, when running pip install the sytem will use the default one (i.e. the one located at /usr/bin/pip)

Shanklin answered 8/4, 2015 at 7:7 Comment(0)
K
48

If you have modified your virtualenvwrapper to point to python3, like I do, add the following line in your .bashrc file :

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

making sure that it's placed before the following line (if you have it):

source /usr/local/bin/virtualenvwrapper.sh

Then, make sure you install the virtualenv and virtualenvwrapper using:

sudo /usr/local/bin/pip3 install virtualenv virtualenvwrapper
Kira answered 26/7, 2016 at 2:5 Comment(4)
Someone should make doing this simpler. Just one command and you have it all.Oba
@KibeCollins Yeah you're right. And it ~should~ be using Python3 by default, but NOOooooo..Sagittarius
This might also be useful: medium.com/@gitudaniel/…Ryder
Thank you for this. Out of all the other posts, this was the actual fix.Driving
S
20

You need to install them under python 2.7.9 by specifying the path to correct version of pip to be used

/usr/local/bin/pip install virtualenv virtualenvwrapper

otherwise, when running pip install the sytem will use the default one (i.e. the one located at /usr/bin/pip)

Shanklin answered 8/4, 2015 at 7:7 Comment(0)
S
0

source /usr/local/bin/virtualenvwrapper_lazy.sh


when use pyenv:

export PYENV_ROOT="${HOME}/.pyenv"

if [ -d "${PYENV_ROOT}" ]; then
    export PATH="${PYENV_ROOT}/bin:${PATH}"
    eval "$(pyenv init -)"
fi
export PATH

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
#important
source /usr/local/bin/virtualenvwrapper_lazy.sh
Sanatory answered 15/12, 2016 at 2:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.