How to fix "No module named pip"
Tested: we reproduced this error and confirmed the fix on Ubuntu 24.04 with Python 3.12 and pip 24.0, November 29, 2026.
The Python you ran has no pip installed. Add it with Python’s own installer, then check:
python3 -m ensurepip --upgrade
python3 -m pip --version
We reproduced the error with a virtual environment created with --without-pip on Python 3.12: python -m pip printed No module named pip, and python -m ensurepip installed pip 24.0 into it.
Which fix fits your setup
| Where you see it | Fix |
|---|---|
| Inside a virtual environment | python -m ensurepip, or delete the folder and recreate it with python3 -m venv .venv |
| Ubuntu or Debian system Python | sudo apt install python3-pip (these systems ship Python without pip) |
| Fedora or RHEL | sudo dnf install python3-pip |
| macOS with Homebrew Python | brew reinstall python, or use a virtual environment |
| Windows | Re-run the python.org installer, choose Modify and tick pip, or run py -m ensurepip |
| A Docker image | Install pip in the Dockerfile, or start from an official python: image, which includes it |
Fix: a virtual environment without pip
Environments created with --without-pip, or by a tool that skipped it, have no pip. Either add it:
.venv/bin/python -m ensurepip
or recreate the environment, which installs pip by default:
rm -rf .venv
python3 -m venv .venv
On Debian and Ubuntu, if python3 -m venv itself fails with ensurepip is not available, install python3-venv first.
Fix: ensurepip isn’t available either
On Debian and Ubuntu, ensurepip is switched off for the system Python. In our test, python3.12 -m ensurepip printed ensurepip is disabled in Debian/Ubuntu for the system python. Use sudo apt install python3-pip there, or work in a virtual environment.
Elsewhere, if ensurepip is missing, the pip project’s own installation page gives a fallback: download get-pip.py from https://bootstrap.pypa.io/get-pip.py and run it with the Python that needs pip (python get-pip.py). Don’t run it against a Linux distribution’s system Python; it bypasses the package manager. We didn’t run get-pip.py ourselves.
Fix: the system Python on Linux
Linux distributions often ship Python without pip. Install their package:
sudo apt install python3-pip # Ubuntu, Debian
sudo dnf install python3-pip # Fedora, RHEL
After that, installing packages into the system Python with pip is blocked on recent Ubuntu and Debian with error: externally-managed-environment. That’s expected; use a virtual environment for your projects, as our externally-managed-environment guide explains.
Confirm it worked
python3 -m pip --version
It should print the pip version and a path inside the Python you meant, for example pip 24.0 from /home/you/project/.venv/lib/python3.12/site-packages/pip (python 3.12).
FAQ
What is ensurepip?
A module that ships with Python and installs the copy of pip bundled with it. python -m ensurepip adds pip to an environment that doesn't have one. Some Linux distributions remove it from the system Python and ask you to install their pip package instead.
Should I use get-pip.py?
Only when ensurepip isn't available and your OS has no pip package. Download it from bootstrap.pypa.io and run it with the Python you want pip for. Don't run it against a system Python your OS manages.
Why does pip work but python -m pip says no module named pip?
The pip command and python belong to different installations. Check with which pip and which python3. Use python -m pip so pip always matches the interpreter you run.
