Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using different versions of python with virtualenvwrapper

I've got various versions of python installed on my Mac using Macports. When I've selected python 2.7 via $ port select python python27, virtualenvwrapper works perfectly.

But if I select another version of python, i.e. 2.6, virtualenvwrapper generates an error message: ImportError: No module named virtualenvwrapper.hook_loader

I checked my .profile and it's setting VIRTUALENVWRAPPER_PYTHON to /opt/local/bin/python, so it seems to me virtualenvwrapper should work regardless of which python I've selected.

Any idea what would cause virtualenvwrapper to generate a .hook_loader error when I switch python versions?

like image 713
wmfox3 Avatar asked Jun 19 '11 10:06

wmfox3


People also ask

Can I install different Python version in virtualenv?

Installing Virtualenv using pip3You must first install a custom version of Python 3. This custom installation of Python 3 will also contain pip3. After it's installed and activated, run the which python3 command as shown in the article. This should return the location of your custom version of Python 3.

How do I specify Python version in virtualenv?

By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.


1 Answers

You can select the python version explicitly

mkvirtualenv -p python3 venvname 

or

mkvirtualenv -p python2.7 venvname 
like image 195
Dos Avatar answered Sep 19 '22 19:09

Dos