Dealing with multiple Python versions and PIP?

后端 未结 23 3532
走了就别回头了
走了就别回头了 2020-11-21 06:58

Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my s

23条回答
  •  生来不讨喜
    2020-11-21 07:31

    The current recommendation is to use python -m pip, where python is the version of Python you would like to use. This is the recommendation because it works across all versions of Python, and in all forms of virtualenv. For example:

    # The system default python:
    $ python -m pip install fish
    
    # A virtualenv's python:
    $ .env/bin/python -m pip install fish
    
    # A specific version of python:
    $ python-3.6 -m pip install fish
    

    Previous answer, left for posterity:

    Since version 0.8, Pip supports pip-{version}. You can use it the same as easy_install-{version}:

    $ pip-2.5 install myfoopackage
    $ pip-2.6 install otherpackage
    $ pip-2.7 install mybarpackage
    

    EDIT: pip changed its schema to use pipVERSION instead of pip-VERSION in version 1.5. You should use the following if you have pip >= 1.5:

    $ pip2.6 install otherpackage
    $ pip2.7 install mybarpackage
    

    Check https://github.com/pypa/pip/pull/1053 for more details


    References:

    • https://github.com/pypa/pip/issues/200
    • http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4

提交回复
热议问题