Dealing with multiple Python versions and PIP?

后端 未结 23 2830
走了就别回头了
走了就别回头了 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:32

    On Linux, Mac OS X and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:

    python2.7 -m pip install SomePackage
    python3.4 -m pip install SomePackage
    

    (appropriately versioned pip commands may also be available)

    On Windows, use the py Python launcher in combination with the -m switch:

    py -2.7 -m pip install SomePackage  # specifically Python 2.7
    py -3.4 -m pip install SomePackage  # specifically Python 3.4
    

    if you get an error for py -3.4 then try:

    pip install SomePackage
    

提交回复
热议问题