Using different versions of python with virtualenvwrapper

wmfox3 picture wmfox3 · Jun 19, 2011 · Viewed 66.1k times · Source

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?

Answer

Dos picture Dos · May 3, 2019

You can select the python version explicitly

mkvirtualenv -p python3 venvname

or

mkvirtualenv -p python2.7 venvname