Run Python 3’s built-in ensurepip bootstrap module (python3 -m ensurepip --upgrade) to install pip directly into your Python 3 installation—or install the OS package (sudo apt install python3-pip on Debian/Ubuntu) or run the official get-pip.py bootstrap script if your system distribution omits ensurepip.

Basic Example

# 1. Recommended (cross-platform): Use Python 3's built-in ensurepip module
python3 -m ensurepip --upgrade

# 2. Upgrade pip to the latest release using python3 -m pip
python3 -m pip install --upgrade pip

# 3. Verify pip is bound specifically to Python 3
python3 -m pip --version
# Output: pip 25.x from /usr/local/lib/python3.x/site-packages/pip (python 3.x)

Key Details & Platform-Specific Methods

  • Always invoke python3 -m pip instead of bare pip or pip3: On systems with multiple Python installations (such as macOS Homebrew, system Python, conda, or virtual environments), bare pip or pip3 can point to a different interpreter than python3. Prefixing every command with python3 -m pip install <package> guarantees packages install into that exact python3 environment.
  • Debian / Ubuntu / WSL (apt) where ensurepip is stripped: Debian-based Linux distributions split ensurepip and venv into separate OS packages (No module named ensurepip). Install both via apt:
    sudo apt update
    sudo apt install python3-pip python3-venv
    
    (Note: On modern Ubuntu 23.04+ and Debian 12+, installing packages globally with pip triggers error: externally-managed-environment [PEP 668]—create a virtual environment with python3 -m venv .venv and install inside it).
  • Fallback bootstrap via official get-pip.py: If both ensurepip and an OS package manager are unavailable (e.g., minimal Docker images or custom builds), download and execute PyPA’s official bootstrapper with python3:
    curl -sS [https://bootstrap.pypa.io/get-pip.py](https://bootstrap.pypa.io/get-pip.py) -o get-pip.py
    python3 get-pip.py
    rm get-pip.py
    
  • Windows (py launcher): Standard installers from python.org include pip by default. If it was unchecked during setup, restore and upgrade it using the Windows Python launcher:
    py -3 -m ensurepip --upgrade
    py -3 -m pip install --upgrade pip
    
  • Creating a virtual environment includes pip automatically: Running python3 -m venv .venv automatically bootstraps a fresh, isolated pip inside .venv/bin/pip (or .venv\Scripts\pip.exe on Windows) without requiring global installation permissions.

Comparison of pip Installation Methods for Python 3

Method Command Platform Requires Internet? Best Used When
ensurepip (Built-in) python3 -m ensurepip --upgrade macOS, Windows, standard Linux builds No (bundled wheel) Restoring or bootstrapping pip into an existing Python 3 installation cleanly.
OS Package Manager sudo apt install python3-pip (or dnf) Ubuntu, Debian, Fedora, RHEL Yes System-managed Python 3 on Linux servers or WSL where ensurepip is omitted.
Virtual Environment (venv) python3 -m venv .venv All platforms No Starting any new Python 3 project (automatically provisions isolated python + pip).
get-pip.py Bootstrapper curl -sS https://bootstrap.pypa.io/get-pip.py | python3 Minimal containers / custom builds Yes Slim Docker images or embedded Python builds lacking ensurepip and OS packages.