How to Install pip on Mac, Windows, and Linux

Tyler Tyler (258)
Total time: 5 minutes 

The Python standard library includes a great set of modules, but many projects will require the use of third-party modules. Python modules are grouped into packages, so in order to use external modules, we'll need to install the appropriate package. That's where pip comes in.

What is pip?

Python packages are maintained in a central repository call PyPI (Python Package Index). It can be pronounced "pie pee eye" or "pie pie", but not "pie pee" or "pee pee" or anything like that. Now, you could download packages directly from this repository yourself, but that would be a pain.

Pip stands for "pip installs packages". It's a command line tool that allows you to install, upgrade, and uninstall Python packages.

In this guide, we'll cover how to install pip for Python on all major platforms.

There are a few options to install pip on MacOS:

Option 1: Use Homebrew (recommended)

Install Homebrew

Homebrew is one of the better package managers for Mac. To install Homebrew, open Terminal and type:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Read more here.

Install pip using Homebrew

Using Homebrew to install python will install the latest Python (Python 3.7 currently), pip, and Setuptools.

brew install python

Option 2: Use easy_install

easy_install is the predecessor to pip, and it comes preinstalled on macOS (along with Python 2). You can use easy_install to install pip for Python 2.

sudo easy_install pip

Download the installer script

Right click on this installer script and select Save As....

Run the installer script

Open the Command Prompt, then navigate to the directory where you downloaded the script.

Now run:

python get-pip.py

The command to install pip on Linux will vary based on the distribution you're using (and the package manager). Below I'll list the common package managers.

APT (Advanced Packaging Tool)

Python 2.x

sudo apt-get install python-pip

Python 3.x

sudo apt-get install python3-pip

Pacman

Python 2.x

sudo pacman -S python2-pip

Python 3.x

sudo pacman -S python-pip

Yum

Python 2.x

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

Python 3.x

sudo yum install python3 python3-wheel