简体   繁体   中英

Installing Pip for Python 3.x

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?

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.

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.

Following the official Documentation it says :

To install pip, securely download get-pip.py :

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Then run the following:

python get-pip.py

OR

python3 get-pip.py

You should already have pip2 and pip3 if you used homebrew to install python2.x and python3.x. Try running pip3 -V in the terminal and see if it works. You can use pip3 install package-name to install python3 packages and pip2 install package-name to install python2 packages.

Run which pip to see the default default path.

如果您具有Python但没有pip,则可以在此处获得官方说明: https//pip.pypa.io/zh/latest/installing/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM