Using different versions of python with virtualenvwrapper

后端 未结 5 1899
天涯浪人
天涯浪人 2021-01-30 16:49

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 p

5条回答
  •  孤街浪徒
    2021-01-30 17:23

    You (the OP) seem to have installed virtualenv and virtualenvwrapper with python2.7, and not with python2.6. If python2.6 is called at the moment your shell loads the virtualenvwrapper.sh script, it is unhappy. Pretty straightforward.

    VIRTUALENVWRAPPER_PYTHON is made for those situations. With it, you can make sure you always use the right version of python, and don't have to always add that -p /path/to/python2.7

    So, I don't agree with Stefano's answer in that case, in the OP's situation, you should have explained clearly in your .bashrc which python to use:

    ...
    export VIRTUALENVWRAPPER_PYTHON=/path/to/your/python2.7
    source /path/to/bin/virtualenvwrapper.sh
    

    Like that it should be ok all the time! Virtualenvwrapper is done to simplify things.

    Also, please note that /opt/local/bin/python must be a symlink to the version of python you select with port python select (check that with ls -l /opt/local/bin/python to be sure).

提交回复
热议问题