How to Install pip on Mac

December 14, 2023

Introduction

Pip is a package management system for installing and managing Python software and libraries. The packages managed by pip are stored in the Python Package Index (PyPI) repository.

In this tutorial, you will learn to install pip on macOS using three methods.

How to install pip on your macOS.

Prerequisites

  • A system running macOS.
  • Python installed.
  • A user account with administrator-level privileges.

How to Install pip on Mac

The recommended way to install pip on Mac is using Python's ensurepip module. This section describes the pip installation via ensurepip and provides two alternative methods:

  • Installing via Homebrew
  • Using get-pip.py installation script.

Method 1: Install pip via ensurepip

Since version 3.4, Python can install pip without utilizing external commands or an internet connection. This feature is available through ensurepip, a module that supports bootstrapping pip to an existing Python installation.

Follow the steps below to install pip with ensurepip:

1. Open a new Terminal window.

2. Run the following command to start the installation:

python3 -m ensurepip

The output confirms the installation was successful.

Install pip via ensurepip on macOS.

Method 2: Install pip on macOS via Homebrew

Another method to install pip on macOS is through Homebrew, an open-source package manager.

Note: If you do not have Homebrew installed on your system, read How to Install Homebrew on Mac.

On Homebrew, pip comes prepackaged with the Python installation. To install pip, install the Python formula with the following command:

brew install python

Homebrew installs the latest Python, pip, and setuptools packages.

Install pip on macOS using Homebrew.

Note: If pip is not in your path after installing via Homebrew, the solution is to re-link. Run brew unlink python && brew link python.

Since macOS already comes with a preinstalled version of Python, the brew command installs a separate copy. Having a separate installation:

  • Allows you to use newer Python versions than those preinstalled on macOS.
  • Adds a layer of protection to your system, as it provides isolation from the system dependencies.

Method 3: Install pip via get-pip.py

Another way to install pip on macOS is using the get-pip.py script. The script automatically downloads and installs the current pip package for Python.

Important: Install pip via get-pip.py only with Python3 or later. This method doesn't work for earlier versions. Learn how to upgrade to Python3.

Follow the steps below to install pip with get-pip.py:

1. Check the Python version to make sure Python3 is installed:

python3 --version
Check Python version on macOS.

2. Download pip by running the following command:

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

The curl command allows you to specify a direct download link. Use the -o option to set the name of the downloaded file.

Download the get-pip.py script via curl.

3. Install the downloaded package:

python3 get-pip.py
Install pip via get-pip.py.

Wait for the installation to finish.

How to Verify pip Installation

To verify that you have installed pip correctly, check the pip version on your system:

pip --version

The output shows which pip version you have on your computer.

Verify your pip installation on macOS.

How to Update pip on Mac

Update pip to a newer version by executing one of the following commands:

  • The ensurepip command with the --upgrade option:
python3 -m ensurepip --upgrade
  • The pip install command with the --upgrade option:
pip install --upgrade pip

Note: To upgrade pip with Homebrew, upgrade your Python version by running brew upgrade python.

Update to a specific pip version by providing the version number to the pip install command:

pip install --upgrade pip==[version]

For example, to update to pip 21.2.4, type:

pip install --upgrade pip==21.2.4

How to Uninstall pip on Mac

Uninstall pip from your system with the following pip command:

pip uninstall pip

When prompted, start the removal by typing Y and pressing Enter. The output confirms the successful uninstallation of pip.

Uninstalling pip using pip.

Conclusion

After reading this article, you should know how to install, update, and remove pip from your macOS system. Pip is a great way to manage and install packages, with over 50,000 packages available in its repository.

If you want to install pip on a different system, refer to one of our other tutorials Install pip on Windows, Install pip on CentOS 7, Install pip on CentOS 8, Install pip on Debian 9 or Install pip on Ubuntu.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Get the Current Date and Time in Python
August 14, 2019

The article shows you how to create a basic Python script that displays the current date and time.
Read more
Python Data Types
April 1, 2021

Every programming language has their own set of built-in data types. In Python, data types provide information about a variable...
Read more
Python SciPy Tutorial - A Guide for Beginners
February 25, 2021

When NumPy is not enough, SciPy has you covered. SciPy is a Python library used for scientific...
Read more
Best Python IDEs And Code Editors
November 6, 2023

An IDE is like a toolbox and a Code editor is like a power tool. In this article, we review 9 IDEs and 5 Python code editors.
Read more