2

I have Python 3.7 and Python 3.6. How to I chose to which version of Python I want my PIP packages?

  • 1
    Possible duplicate of [pip: dealing with multiple Python versions?](https://stackoverflow.com/questions/2812520/pip-dealing-with-multiple-python-versions) – Sarah Strand Aug 15 '18 at 21:49

4 Answers4

7

On Linux the @jwodder answer is fine, but on Windows use the Python Launcher, which is normally installed by default. You specify the version of Python to launch as -X.Y, e.g.:

py -3.6 -m pip install ...
Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
3

You use the version of pip that corresponds to the desired Python version. The most universally effective way is to run pythonX.Y -m pip install ..., where X.Y is replaced with the Python version number, though running just pipX.Y install ... may also work under some circumstances.

jwodder
  • 54,758
  • 12
  • 108
  • 124
1

use python -m pip where python is the version of python you want to install to

Sarah Strand
  • 119
  • 8
1

I would suggest to use the newer and (now) recommended way of installing Python application dependencies: pipenv. You can consider pipenv to be the better pip (pip + virtualenv handling + proper depedency management). Using pipenv you create a Pipfile and you can specify the exact python_version you want to use in that file. Since I started using pipenv in my projects most headaches I had previously with Python dependency and version management are gone.

Dodge
  • 3,219
  • 3
  • 19
  • 38
Torsten Engelbrecht
  • 13,318
  • 4
  • 46
  • 48