Installing Pip for Python 3.x

10,776

Solution 1

Homebrew installs pip for you when you install Python. brew install python3 would have installed Python 3.6.0, and also pip3. You can then type pip3 in the terminal to run pip for Python 3. You don't need to use easy_install at all.

Solution 2

The article you posted is plain wrong stating that you can install the pip3 package. (If you check it out, you'll see that it tries to resolve https://pypi.python.org/simple/pip3/, which doesn't exist.)

Installing pip for a specific environment is done by executing the script (in this instance, easy_install) in the context of that specific python environment.

Right now, your easy_install script is running using your python2 environment.

When you install two python environments, the easy_install script will be defaulting to one of them. In the background, there are actually two easy_install scripts for you. One, easy_install-2.x and one easy_install-3.x, x being the relevant minor version.

So to install pip using the python3 easy_install, just run:

$ sudo easy_install-3.x pip

Or, alternatively, just run the easy_install script using python3:

$ sudo python3 $(which easy_install) pip

Regardless of that, I think you would be better off using the get-pip.py (https://bootstrap.pypa.io/get-pip.py) script instead which would make your life easier.

Share:
10,776
user2762934
Author by

user2762934

Updated on June 14, 2022

Comments

  • user2762934
    user2762934 almost 2 years

    I am following instructions from http://www.leighsheneman.com/2014519easy-python-setup-for-a-mac/ to setup my mac for a development environment. I have successfully installed Python 2 and Python 3 via Homebrew, and after some steps to install related packages like SciPy, I get to the point of installing pip. Pip for Python 2.x installs perfectly with no trouble, via the command sudo easy_install pip. When it comes to pip for Python 3, I tried the command sudo easy_install pip3 as mentioned in the document I am following, and receive this error:

    Searching for pip3
    Reading https://pypi.python.org/simple/pip3/
    Couldn't find index page for 'pip3' (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading https://pypi.python.org/simple/
    No local packages or working download links found for pip3
    error: Could not find suitable distribution for Requirement.parse('pip3')
    

    What could be the problem in this case?

  • nir0s
    nir0s about 7 years
    That's misleading (or plain incorrect). There is no pip2 and pip3 package managers. There is only pip installed in the context of a specific python environment.
  • Manan Mehta
    Manan Mehta about 7 years
    @nir0s If you only have one version of python in the environment, then you're right. But what if you have two versions of python in the same environment? Will you not need both the package managers?
  • Manan Mehta
    Manan Mehta about 7 years
    @nir0s I could be wrong. Could you please give an explanation as to how <code>pip</code> works when you have two python versions in the same environment?
  • nir0s
    nir0s about 7 years
    There are no pip2 and pip3 packages in pypi. pip2 and pip3 are links to pip in the relevant python environment. You can't "install pip2". You can only "install pip in python2"
  • nir0s
    nir0s about 7 years
    My previous comment was misleading. They area not "links". They are scripts with a shebang pointing to the relevant python executable (e.g. #!/usr/bin/python2).
  • Manan Mehta
    Manan Mehta about 7 years
    @nir0s I see. I stand corrected. I have changed my answer :) Thank you for the explanation! Upvoted :)