macOS
OS X
pip installation
Python
tech tutorial

How do I install pip on macOS or OS X?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

On macOS, installing pip is usually less about downloading a separate tool and more about making sure you are using the right Python interpreter. Many "pip is missing" problems are really environment mismatches caused by mixing python3, pip3, Homebrew Python, and virtual environments.

First Check Whether pip Already Exists

Before installing anything, inspect the active Python:

bash
which python3
python3 --version
python3 -m pip --version

If python3 -m pip --version works, pip is already installed for that interpreter. In that case, you may only need to upgrade it:

bash
python3 -m pip install --upgrade pip

Using python3 -m pip is important because it guarantees you are calling the pip attached to that exact Python executable.

Try ensurepip First

Many Python builds include the standard-library bootstrap module ensurepip. If it is available, it is often the cleanest way to install or repair pip:

bash
python3 -m ensurepip --upgrade
python3 -m pip --version

If that succeeds, you have a working pip without needing extra downloads.

Install a Modern Python Distribution if Needed

If the current interpreter is too old, incomplete, or missing packaging support, installing a current Python distribution is often easier than trying to repair a broken one.

On macOS, Homebrew is a common path:

bash
1brew update
2brew install python
3python3 --version
4python3 -m pip --version

After that, reopen the shell and confirm that python3 resolves to the Homebrew-installed interpreter you actually want to use.

Use the Bootstrap Script Only as a Fallback

If ensurepip is unavailable and you do not want to install a new Python distribution immediately, the official bootstrap script is a fallback:

bash
curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
python3 -m pip --version

This works, but it is better treated as a recovery path than as the default long-term setup strategy.

Use Virtual Environments for Real Projects

Once pip works, the next important step is to avoid installing every package globally. Virtual environments keep project dependencies isolated:

bash
1python3 -m venv .venv
2source .venv/bin/activate
3python -m pip install --upgrade pip
4python -m pip install requests
5python -m pip list

Inside the virtual environment, python and pip point at the local project environment instead of the global interpreter.

That makes dependency management much more predictable.

Verify the Interpreter and Installer Match

If pip seems to work but imports still fail, check whether packages are being installed into a different interpreter than the one your scripts actually use:

bash
python3 -c "import sys; print(sys.executable)"
python3 -m pip show pip
python3 -m pip show setuptools

The paths in that output should line up with the interpreter you intend to use.

Good Long-Term Habits

On macOS, the safest habits are:

  • use python3, not plain python, unless you know how your shell resolves it
  • use python3 -m pip, not plain pip
  • create a virtual environment for project work
  • avoid sudo pip for normal development

Those habits prevent most of the path, permission, and package-location problems people associate with Python on macOS.

Common Pitfalls

The biggest mistake is invoking plain pip, which may belong to a different interpreter than the python3 command you use to run code.

Another issue is mixing global installs and virtual-environment installs without realizing which environment is active.

People also waste time patching very old or unusual Python installations when installing a current maintained Python distribution would be simpler and safer.

Finally, sudo pip is a poor default. It can create permission problems and mixes project dependencies into system-level locations unnecessarily.

Summary

  • Check whether your active python3 already has pip before installing anything.
  • Use python3 -m ensurepip --upgrade first when it is available.
  • Install a current Python distribution if the existing interpreter is incomplete or outdated.
  • Prefer virtual environments for project dependencies.
  • Standardize on python3 -m pip so the installer and interpreter stay aligned.

Course illustration
Course illustration

All Rights Reserved.