How to install pip with Python 3?

后端 未结 21 1273
夕颜
夕颜 2020-11-22 01:06

I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.

How can I install pip with Python 3?

21条回答
  •  心在旅途
    2020-11-22 01:51

    Older version of Homebrew

    If you are on macOS, use homebrew.

    brew install python3 # this installs python only
    brew postinstall python3 # this command installs pip
    

    Also note that you should check the console if the install finished successfully. Sometimes it doesn't (e.g. an error due to ownership), but people simply overlook the log.


    UPDATED - Homebrew version after 1.5

    According to the official Homebrew page:

    On 1st March 2018 the python formula will be upgraded to Python 3.x and a python@2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link --force). We will maintain python2, python3 and python@3 aliases.

    So to install Python 3, run the following command:

    brew install python3
    

    Then, the pip is installed automatically, and you can install any package by pip install .

提交回复
热议问题