Pip Error — ERROR: No module named pip
Running pip install --upgrade pip can leave pip in a broken state if the reinstall step fails mid-way. This post shows how to get pip working again without reinstalling Python.
[01] The Problem — pip Disappears After an Upgrade Attempt
When pip upgrades itself it first uninstalls the current version, then installs the new one. If that second step fails — due to a permission error, a disk-full condition, or an antivirus lock — the old pip is already gone and the new one never landed. The result is a Python environment with no pip at all.
Symptoms
- After running
pip install --upgrade pip, the terminal showsAccess is denied. - Any follow-up command using
pipraisesNo module named pip.
1
2
3
4
5
$ pip install --upgrade pip
ERROR: Access is denied.
$ python -m pip install --upgrade pip
C:\...\python.exe: No module named pip

Figure 1. No module named pip printed after a failed self-upgrade leaves no pip installed.
Why This Happens
pip install --upgrade pip is a special case: pip is asked to replace a file it is currently running from. On Windows especially, the file lock held by the running process can block the write, causing the two-phase uninstall-then-install to abort between phases.
| Phase | What happens on failure |
|---|---|
| Uninstall old pip | Old pip files are removed |
| Install new pip | Write blocked → new pip files never appear |
| Net result | No pip at all |
[02] Solution — Reinstall pip
Option A: get-pip.py (works everywhere)
Download the official pip bootstrapper and run it directly with your Python interpreter. This bypasses pip’s self-upgrade mechanism entirely.
1
2
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
On Windows without curl:
1
2
3
# PowerShell
Invoke-WebRequest -Uri https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py
python get-pip.py
After running get-pip.py, verify the installation:
1
pip --version

Figure 2. get-pip.py successfully reinstalls pip and prints the new version.
Option B: ensurepip (built into Python 3.4+)
Python ships with a built-in module called ensurepip that can install pip without any network download:
1
python -m ensurepip --upgrade
If this raises ensurepip is disabled in this environment (common in system Python on Debian/Ubuntu), use Option A or install the distro package:
1
sudo apt install python3-pip
Option C: Upgrade safely in the future
To avoid the permission issue on Windows, always run the upgrade through the module interface rather than through the pip script itself:
1
python -m pip install --upgrade pip
This invokes pip as a Python module rather than an executable, which sidesteps the file-lock problem on most systems.
[03] Troubleshooting
| Symptom | Fix |
|---|---|
Access is denied on Windows |
Run terminal as Administrator, or use python -m pip
|
ensurepip is disabled |
Use get-pip.py or apt install python3-pip
|
| pip installs but wrong version | Run pip install --upgrade pip after bootstrapping |
| Inside a venv, pip still missing | Recreate venv: python -m venv --upgrade-deps venv
|
After recovery, check the pip version and the Python it belongs to to make sure everything is consistent:
1
2
3
4
pip --version
# Example output: pip 24.0 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
which pip # Linux/macOS
where pip # Windows