python – How do I install pip on macOS or OS X?

python – How do I install pip on macOS or OS X?

pips documentation lists the supported mechanisms to install it: https://pip.pypa.io/en/stable/installation/#supported-methods

It is generally recommended to avoid installing pip on the OS-provided python commands, and to install Python via the https://python.org installers or using something like Homebrew or pyenv.

Python 3.4+ will have ensurepip, so if youre unable to run python3 -m pip — run python3 -m ensurepip and itll install pip for you.

If youre using an end-of-life version of Python, you can use get-pip.py instead.


Old answer (outdated, and results in a broken installation)

easy_install pip

If you need admin privileges to run this, try:

sudo easy_install pip

⚡️ TL;DR — One-line solution.

Run the following command for Python v2.7 (default on mac as of 2021)

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python

Run the following command for Python v3

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

OR the following if you have it installed as python3

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

Another gif you said? Here ya go!

GIF


FOLLOWING USED TO WORK in 2019 and before

All you had to do was:

sudo easy_install pip

2019: ⚠️easy_install has been deprecated. Check Method #2 below for preferred installation!

Details:

⚡️ OK, I read the solutions given above, but heres an EASY solution to install pip.

The macOS comes with Python installed. But to make sure that you have Python installed open the terminal and run the following command.

python --version

If this command returns a version number that means Python exists. This also means that you already have access to easy_install considering you are using macOS/OSX.

ℹ️ Now, all you have to do is run the following command.

sudo easy_install pip

After that, pip will be installed and youll be able to use it for installing other packages.

Let me know if you have any problems installing pip this way.

Cheers!

P.S. I ended up blogging a post about it. QuickTip: How Do I Install pip on macOS or OS X?


UPDATE (Jan 2019): METHOD #2: Two line solution —

easy_install has been deprecated. Please use get-pip.py instead.

Download and install PIP

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

python – How do I install pip on macOS or OS X?

Im surprised no-one has mentioned this – since 2013, python itself is capable of installing pip, no external commands (and no internet connection) required.

sudo -H python -m ensurepip

This will create a similar install to what easy_install would.

Leave a Reply

Your email address will not be published. Required fields are marked *