Install pip for Python 3

17,313

Solution 1

From Python 3.4 pip is baked into standard Python. You can use it like,

python3 -m pip install SomePackage

as mentioned in the Python Docs.

Solution 2

The guaranteed cross-platform way to run a module 'mod' with a particular python version 'pythonx' is

pythonx -m mod

On Windows, with the py launcher, I might run any of

py -2.7 -m pip
py -3.5 -m pip
py -3.6 -m pip

There is then no question which python and pip combination I will get. Other systems with one 2.x and 3.x version installed can use

python2 -m pip
python3 -m pip
Share:
17,313
Harsh Khajuria
Author by

Harsh Khajuria

4th year Computer Science Undergraduate at NIT Srinagar.

Updated on June 12, 2022

Comments

  • Harsh Khajuria
    Harsh Khajuria almost 2 years

    When I type python3 --version in terminal it shows Python 3.6.0.

    When I type in pip --version it shows

    pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
    

    How do I get it from Python/2.7 to Python/3.6?

    • m0nhawk
      m0nhawk almost 7 years
      What about pip3 --version?
    • Harsh Khajuria
      Harsh Khajuria almost 7 years
      pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python‌​3.6/site-packages (python 3.6)
    • m0nhawk
      m0nhawk almost 7 years
      So, you have pip already installed.
    • Harsh Khajuria
      Harsh Khajuria almost 7 years
      I was basically watching a Django tutorial by Derek Banas and he said that it should show Python/3.x Version when I type in pip --version
    • Harsh Khajuria
      Harsh Khajuria almost 7 years
      So what is going on in here?
    • m0nhawk
      m0nhawk almost 7 years
      You just need to use pip3 instead of pip for Python 3.6.0.
    • Harsh Khajuria
      Harsh Khajuria almost 7 years
      How do you know all this stuff? Can you point me to some documentation that I can read so that I can figure this stuff by myself? Thank you.
    • narendra-choudhary
      narendra-choudhary almost 7 years
      @HarshKhajuria Either change default python version to python3 or use virtualenv. Using virtualenv is recommended way to go.
  • Vikram Hosakote
    Vikram Hosakote over 5 years
    This worked for me and I was able to install the requests package for python3 by doing python3 -m pip install requests on Mac.