Use different Python version with virtualenv

后端 未结 30 3340
自闭症患者
自闭症患者 2020-11-21 05:03

I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtuale

30条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 05:25

    There is an easier way,

    virtualenv venv --python=python2.7
    

    Thanks to a comment, this only works if you have python2.7 installed at the system level (e.g. /usr/bin/python2.7).

    Otherwise, if you are using homebrew you can use the path to give you what you want.

    virtualenv venv --python=/usr/local/bin/python
    

    You can find the path to your python installation with

    which python
    

    This will also work with python 3.

    which python3
    >> /usr/local/bin/python3
    virtualenv venv --python=/usr/local/bin/python3
    

    Ultimately condensing to:

    virtualenv venv -p `which python`
    virtualenv venv -p `which python3`
    

提交回复
热议问题