How to install pip with Python 3?

后端 未结 21 1276
夕颜
夕颜 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:48

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

    Then run the following:

    python get-pip.py
    

    Be cautious if you're using a Python install that's managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.

    Refer: PIP Installation

    0 讨论(0)
  • 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 <package>.

    0 讨论(0)
  • 2020-11-22 01:51

    If your Linux distro came with Python already installed, you should be able to install PIP using your system’s package manager. This is preferable since system-installed versions of Python do not play nicely with the get-pip.py script used on Windows and Mac.

    Advanced Package Tool (Python 2.x)

    sudo apt-get install python-pip
    

    Advanced Package Tool (Python 3.x)

    sudo apt-get install python3-pip
    

    pacman Package Manager (Python 2.x)

    sudo pacman -S python2-pip
    

    pacman Package Manager (Python 3.x)

    sudo pacman -S python-pip
    

    Yum Package Manager (Python 2.x)

    sudo yum upgrade python-setuptools
    sudo yum install python-pip python-wheel
    

    Yum Package Manager (Python 3.x)

    sudo yum install python3 python3-wheel
    

    Dandified Yum (Python 2.x)

    sudo dnf upgrade python-setuptools
    sudo dnf install python-pip python-wheel
    

    Dandified Yum (Python 3.x)

    sudo dnf install python3 python3-wheel
    

    Zypper Package Manager (Python 2.x)

    sudo zypper install python-pip python-setuptools python-wheel
    

    Zypper Package Manager (Python 3.x)

    sudo zypper install python3-pip python3-setuptools python3-wheel
    
    0 讨论(0)
  • 2020-11-22 01:53

    Update 2015-01-20:

    As per https://pip.pypa.io/en/latest/installing.html the current way is:

    wget https://bootstrap.pypa.io/get-pip.py
    python get-pip.py
    

    I think that should work for any version


    Original Answer:

    wget http://python-distribute.org/distribute_setup.py
    python distribute_setup.py
    easy_install pip
    
    0 讨论(0)
  • 2020-11-22 01:55

    pip is installed together when you install Python. You can use sudo pip install (module) or python3 -m pip install (module).

    0 讨论(0)
  • 2020-11-22 01:56
    python3 -m ensurepip
    

    I'm not sure when exactly this was introduced, but it's installed pip3 for me when it didn't already exist.

    0 讨论(0)
提交回复
热议问题