Guides

How to install pip on Windows, Linux and macOS, and use pip install

How to install pip on Windows, Debian, Ubuntu and macOS: check with python3 -m pip --version, fix a missing pip, use pip install and upgrade pip safely.

Published ~9 min read
On this page

Short answer: pip usually comes with Python. Check with python3 -m pip --version (py -m pip --version on Windows). If it is missing, run sudo apt install python3-pip python3-venv on Debian and Ubuntu, or py -m ensurepip --upgrade with a python.org Python on Windows. Then install packages with python3 -m pip install NAME, inside a virtual environment.

check first
python3 -m pip --version     # Linux · macOS
py -m pip --version          # Windows
Output on Debian 12
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)

That line tells you three things: pip is installed, which version it is, and which Python it belongs to (the part in brackets). The two other answers you can get:

  • /usr/bin/python3: No module named pip: Python is there, pip is not. Install it for your system below.
  • python3: command not found or Windows’ Python was not found: Python itself is missing, so start with python: command not found.

If the bare pip command is what fails while python3 -m pip works, the error page pip: command not found has that case. This guide is about getting pip onto a system and using pip install well.

How do I install pip on Windows?

The installers from python.org include pip, so on Windows “installing pip” mostly means installing Python with the right boxes ticked, then calling pip through the py launcher.

  1. 1Run the python.org installer

    On the first screen, tick Add python.exe to PATH (it is off by default). Under Customize installation, the pip feature is ticked by default; leave it on. Since Python 3.14, python.org also offers the Python install manager for Windows, which installs runtimes with py install; pip comes with those runtimes too, as it does with Python from the Microsoft Store.

  2. 2Open a new terminal and check
    PowerShell or cmd
    py --version
    py -m pip --version

    A terminal that was open during the install keeps its old PATH, so open a fresh one.

  3. 3If pip is missing, bootstrap it
    PowerShell or cmd
    py -m ensurepip --upgrade
    py -m pip --version

    ensurepip is part of the Python standard library and installs the pip copy that ships inside Python, with no download.

  4. 4Install packages with py -m pip
    PowerShell or cmd
    py -m pip install requests

'pip' is not recognized as an internal or external command means pip is installed but its folder is not on the PATH. pip.exe lives in the Scripts folder of the Python install, for a per-user install %LOCALAPPDATA%\Programs\Python\Python3XX\Scripts. Either keep using py -m pip, which needs no PATH entry, or run the installer again, choose Modify, and tick Add Python to environment variables under Advanced Options. The same steps work on Windows Server 2022 and 2019, where curl.exe is also available for the get-pip.py route.

How do I install pip on Linux?

DistributionCommand
Debian, Ubuntusudo apt install python3-pip python3-venv
Rocky Linux, AlmaLinux, Fedora, RHELsudo dnf install python3-pip
Alpineapk add py3-pip
Arch Linuxsudo pacman -S python-pip
openSUSEsudo zypper install python3-pip

Use the package manager on Linux, not get-pip.py: the system Python belongs to the distribution, and its tools depend on it. Debian 12’s python3-pip is pip 23.0.1 and installs three names for the same program, /usr/bin/pip, pip3 and pip3.11. It also recommends build-essential and python3-dev, so apt pulls in a full compiler toolchain by default. That helps when a package has to be compiled; on a small server that only installs ready-built wheels, add --no-install-recommends.

Then: error: externally-managed-environment

On Debian 12 and later and Ubuntu 23.04 and later, the next step usually fails. Here is a plain pip install outside a virtual environment on Debian 12:

python3 -m pip install on Debian 12 (shortened)
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    ...
hint: See PEP 668 for the detailed specification.

pip install --user is refused the same way. That is intended (PEP 668): pip stays out of the Python that apt manages. Install into a virtual environment instead, or use pipx for command-line tools:

Debian · Ubuntu
python3 -m venv ~/venvs/app
. ~/venvs/app/bin/activate
python -m pip install requests      # goes into ~/venvs/app, nothing system-wide changes

sudo apt install -y pipx            # for tools you run as commands
pipx install httpie

Every option, including why --break-system-packages is the last resort, is in the externally-managed-environment section of the pip error guide.

How do I install pip on macOS?

The python.org installer for macOS includes pip; call it as pip3 or python3 -m pip. Homebrew’s Python (brew install python) includes pip3 as well, but is marked externally managed like Debian’s, so use a venv there. The python3 that comes with Apple’s Command Line Tools also has pip3. None of them installs a bare pip; the macOS section of the error guide shows how to add one.

ensurepip or get-pip.py: which one?

pip’s own installation guide (pip.pypa.io) lists two supported methods for a Python that has no pip:

  • python -m ensurepip --upgrade installs the pip copy bundled with Python itself, offline. Debian and Ubuntu move ensurepip into the python3.X-venv package and do not let you use it on the system Python, so there it only serves venv.
  • get-pip.py downloads the newest pip. Take it only from https://bootstrap.pypa.io/get-pip.py, the address pip’s documentation gives, and only for a Python you built or installed yourself (python.org, a source build, the Windows embeddable package), never for a distribution’s system Python.
get-pip.py
# Linux · macOS
curl -fsSLO https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

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

For an old Python that current pip no longer supports, the same site keeps versioned copies under https://bootstrap.pypa.io/pip/3.X/get-pip.py. The Windows embeddable package ships without pip and without site enabled: uncomment import site in its python3XX._pth file first, or installed packages will not be found.

How do I use pip install?

TaskCommand
Install a packagepython3 -m pip install requests
An exact versionpython3 -m pip install requests==2.32.3
A version range (quote it)python3 -m pip install "requests>=2.31,<3"
Upgrade a packagepython3 -m pip install --upgrade requests
Everything in a requirements filepython3 -m pip install -r requirements.txt
The project in this folder, editablepython3 -m pip install -e .
A wheel filepython3 -m pip install ./pkg-1.0-py3-none-any.whl
From a Git repositorypython3 -m pip install "git+https://github.com/OWNER/REPO.git@v1.2.0"
Show what is installedpython3 -m pip list
Details of one packagepython3 -m pip show requests
Check for broken dependenciespython3 -m pip check
Remove a packagepython3 -m pip uninstall requests

Inside an active venv, pip and python already point into it, so plain pip install requests is fine there. Quote anything with > or < in it. Unquoted, the shell reads them as redirection: pip install requests>=2.31 installs the newest requests and writes pip’s output into a file called =2.31, and pip install requests<3 fails because there is no file named 3 to read from.

A full round trip with a small local package in a venv looks like this:

Example output (local test package, path shortened)
$ python -m pip install ./hello
...
Successfully built hello
Installing collected packages: hello
Successfully installed hello-0.1.0

$ python -m pip uninstall -y hello
Found existing installation: hello 0.1.0
Uninstalling hello-0.1.0:
  Successfully uninstalled hello-0.1.0

pip, pip3 or python -m pip?

pip3 is the name that makes clear you mean Python 3, from the years when pip could still mean Python 2. On Debian 12 all three names run the same program, and inside a venv pip, pip3 and pip3.X all belong to that venv. The safe habit is python3 -m pip (or py -m pip on Windows): it always uses the pip of the exact Python you name, so packages never land in a different interpreter than the one that runs your code. When in doubt, pip --version names that interpreter in brackets.

How do I upgrade pip?

inside a venv, or with a python.org Python
python -m pip install --upgrade pip     # Linux · macOS
py -m pip install --upgrade pip         # Windows
  • On Windows, use the -m form. pip install --upgrade pip stops with ERROR: To modify pip, please run the following command: followed by the python.exe -m pip version, because Windows cannot replace the pip.exe that is running.
  • On Debian and Ubuntu, leave the system pip to apt. sudo apt install --only-upgrade python3-pip brings what the release supports. Upgrading it with pip itself is refused as externally managed, and forcing it leaves two pips that apt and pip both think they own. A venv gets its own pip, which you can upgrade freely.
  • “[notice] A new release of pip is available” after an install is information, not an error. In a venv, run the command it suggests; on the system Python, ignore it.

pip install pip on a working pip only answers Requirement already satisfied; it needs --upgrade to do anything. And pip cannot install itself where it is missing: that is the job of apt, ensurepip or get-pip.py.

requirements.txt: install a project’s dependencies

requirements.txt
# one requirement per line
requests==2.32.3
flask>=3.0,<4
gunicorn
bash · zsh
python3 -m venv .venv && . .venv/bin/activate
python -m pip install -r requirements.txt
python -m pip freeze > requirements.txt     # write the exact versions back

pip freeze lists every package in the current environment with its exact version, so run it from the project’s venv: outside one it dumps the whole system Python. A package installed from a local folder or Git appears as name @ file:///… or name @ git+https://… rather than with a version number. python -m pip uninstall -r requirements.txt -y removes the listed packages again; uninstall never removes their dependencies, so for a clean slate delete the venv and create it anew.

How do I uninstall pip?

  • Debian and Ubuntu: sudo apt remove python3-pip.
  • A venv: delete the venv folder; its pip goes with it.
  • Windows or a python.org Python: py -m pip uninstall pip (python3 -m pip uninstall pip on macOS). ensurepip brings it back.

Common pip install errors

MessageCauseFix
error: externally-managed-environmentpip outside a venv on Debian 12+, Ubuntu 23.04+venv or pipx
'pip' is not recognized as an internal or external commandWindows: the Scripts folder is not on the PATHpy -m pip, or add Python to the PATH
No module named pipThis Python has no pipapt, dnf, apk or ensurepip
Could not find a version that satisfies the requirementTypo in the name, no build for your Python version or platform, or no networkCheck the name on PyPI and python3 --version
The script … is installed in '…' which is not on PATHCommands went to ~/.local/bin or a Scripts folderAdd that folder to the PATH
Microsoft Visual C++ 14.0 or greater is requiredWindows: no wheel, so the package needs compilingInstall Microsoft C++ Build Tools, or a version that ships a wheel
KilledThe build ran out of memoryAdd swap or RAM

“Could not find a version” looks like this (here from a package name that does not exist, on Debian 12 with pip 23.0.1):

python -m pip install with an unknown name
ERROR: Could not find a version that satisfies the requirement vmh-no-such-package-xyz (from versions: none)
ERROR: No matching distribution found for vmh-no-such-package-xyz

(from versions: none) means pip found nothing usable at all: a wrong name, an index it cannot reach, or a package with no release for your Python version. A list of versions in the brackets means the package exists, but none of those fits your version pin or your Python. If you work with conda, install with conda first and pip only for what conda lacks, inside the same environment; a missing conda command is its own fix: conda: command not found.

Frequently asked

How do I install pip on Windows?

Install Python from python.org with the pip feature ticked (it is by default) and Add python.exe to PATH ticked, then open a new terminal and run py -m pip --version. If pip is missing, py -m ensurepip --upgrade installs the copy bundled with Python. If 'pip' is not recognized as a command, use py -m pip, which needs no PATH entry.

How do I install pip on Ubuntu or Debian?

Run sudo apt install python3-pip python3-venv. Then install packages inside a virtual environment (python3 -m venv .venv, then .venv/bin/pip install NAME), because Debian 12 and later and Ubuntu 23.04 and later refuse pip install into the system Python with error: externally-managed-environment.

How do I update pip?

Inside a virtual environment, or with a python.org Python, run python -m pip install --upgrade pip (py -m pip install --upgrade pip on Windows, where plain pip install --upgrade pip stops with 'To modify pip, please run the following command'). On Debian and Ubuntu, leave the system pip to apt.

What is the difference between pip and pip3?

pip3 names the pip for Python 3, from the years when pip could still mean Python 2. On current systems both usually run the same program, and inside a virtual environment they always do. python3 -m pip (py -m pip on Windows) is the safe form, because it uses the pip of exactly that interpreter.

Related articles

All guides

pip: command not found, and the externally-managed-environment error

Install pip the right way on Debian, Ubuntu, Rocky, Alpine and macOS, and fix 'externally-managed-environment' with a venv or pipx instead of breaking apt.

python: command not found? Fix it on Linux, macOS and in Docker

Modern distros ship python3 but no python command. Fix 'python: command not found' on Debian, Ubuntu, Rocky, Alpine, macOS and Docker without breaking apt.

conda: command not found? Initialise conda in bash and zsh

Run ~/miniconda3/bin/conda init bash (or zsh), then open a new terminal. Fixes conda: command not found after install, on macOS zsh, cron, Docker, Windows.

How to install Node.js on Ubuntu, Debian and Windows, and update Node and npm

Install Node.js the right way: NodeSource or nvm on Ubuntu and Debian, the MSI on Windows Server. Check node -v, update Node and npm, run it as a service.

How to check the Python version on Windows, Linux and macOS, and in code

How to check Python version: python3 --version on Linux and macOS, py --version in cmd, sys.version_info in code, plus venvs, pip and several versions.

How to install Python on Ubuntu and Debian: python3, venv, pip and newer versions

Install Python on Ubuntu or Debian: which python3 each release ships, apt install python3-venv python3-pip, virtual environments and newer versions.

How to install SQLite on Ubuntu, Debian and Windows, and use the sqlite3 shell

Install SQLite with apt install sqlite3 or winget on Windows, then use the sqlite3 shell (.tables, .mode, .import, .backup), WAL mode and Python's sqlite3.