How do I install pip on macOS or OS X?
I spent most of the day yesterday searching for a clear answer for installing pip
(package manager for Python). I can't find a good solution.
How do I install it?
pip's 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 you're unable to run python3 -m pip
-- run python3 -m ensurepip
and it'll install pip for you.
If you're 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!
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 here's 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 you'll 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
I'm 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.
You can install it through Homebrew on OS X. Why would you install Python with Homebrew?
The version of Python that ships with OS X is great for learning but it’s not good for development. The version shipped with OS X may be out of date from the official current Python release, which is considered the stable production version. (source)
Homebrew is something of a package manager for OS X. Find more details on the Homebrew page. Once Homebrew is installed, run the following to install the latest Python, Pip & Setuptools:
brew install python
On Mac:
-
Install easy_install
curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python
-
Install pip
sudo easy_install pip
-
Now, you could install external modules. For example
pip install regex # This is only an example for installing other modules