Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

virtualenv - problems with python and virtualenvwrapper after updating: No module named virtualenvwrapper

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...