You just upgraded Python—maybe from 3.9 to 3.11, or from 3.10 to 3.12—and the next time you tried to install a package with pip, you got this error:
ModuleNotFoundError: No module named 'pip'
This happens often when you install a new Python version over an old one without uninstalling the old one first. Or when you use a package manager like Homebrew on macOS and it upgrades Python but doesn't carry the pip module over. The new Python interpreter can run fine, but it has no pip installed inside its own folder.
The root cause is simple: pip is a separate package, not a core part of Python. When you run python -m pip, the interpreter looks for pip in its own lib/site-packages. If that directory is empty or doesn't have pip, you get the module not found error. The old pip you had was tied to the old Python version, and it didn't survive the upgrade.
There are two solid ways to fix this, and both are quick. I'll show you both.
Fix 1: Use ensurepip (the built-in tool)
Starting with Python 3.4, every official Python installer includes a tool called ensurepip. It's tiny and does exactly what we need: it installs pip into your current Python environment.
Here's how to run it, step by step.
- Open a terminal or command prompt. On Windows, press
Win + R, typecmd, and hit Enter. On macOS, open Terminal from Applications > Utilities. - Check your Python version first. Type
python --versionand press Enter. You should see something likePython 3.11.2. Make sure it's the version you just upgraded to. If you see nothing or an error, you might have multiple Python installs. We'll handle that in Fix 2. - Run ensurepip. Type this and press Enter:
python -m ensurepip --upgradeOn macOS, you might need to use
python3instead ofpythonif your system only recognizespython3. Same command, just swap the word. - Wait for it to finish. You should see output like
Looking in links: ...and thenSuccessfully installed pip-XX.X. That means it worked. - Verify pip works. Type
pip --versionand press Enter. If it shows a version number, you're good. If it sayspip is not recognizedorcommand not found, don't panic—the module is installed, but the pip executable might not be on your PATH. Trypython -m pip --versioninstead. That should work.
If ensurepip works, you're done. But there are cases where ensurepip itself is missing—especially if you built Python from source or you're using a minimal distribution. That's when you move to Fix 2.
Fix 2: Use get-pip.py (the official installer script)
The Python Software Foundation provides a script called get-pip.py that downloads and installs pip. It's the same script that the official installer runs behind the scenes. You can run it anywhere.
- Download get-pip.py. Open your browser and go to https://bootstrap.pypa.io/get-pip.py. Save the file to your Downloads folder. Don't worry about the file size—it's just a few hundred kilobytes.
- Open a terminal in the Downloads folder. On Windows, open File Explorer, go to Downloads, then press Shift + Right-click on an empty area and choose "Open PowerShell window here" or "Open command window here" (depending on your Windows version). On macOS, open Terminal and type
cd ~/Downloads. - Run the script. Type this and press Enter:
python get-pip.pyAgain, if you're on macOS or your system uses
python3, use that instead. - Watch the output. You should see it download pip, then install it, and finally print
Successfully installed pip-XX.X. That's your confirmation. - Test pip. Run
pip --versionorpython -m pip --version. One of those should give you a version number.
What if it still fails?
If you've tried both methods and pip still isn't recognized, here are the usual culprits.
You have multiple Python installations
This is the most common issue. You might have Python 3.8 in C:\Python38 and Python 3.11 in C:\Program Files\Python311. When you run python in the terminal, it picks one of them—maybe the old one. So you're installing pip for the old Python, not the new one.
To see which Python you're actually running, type where python on Windows or which python3 on macOS. It will list the paths. Compare that to the Python you think you're using. If they don't match, you need to either update your PATH or explicitly call the full path to the Python interpreter you want.
For example, on Windows, if the new Python is at C:\Program Files\Python311\python.exe, run:
C:\Program Files\Python311\python.exe -m ensurepip --upgrade
Your PATH is missing the pip script directory
Even if pip is installed as a module, the pip command won't work if the Scripts folder (on Windows) or bin folder (on macOS) isn't in your PATH. But python -m pip will always work because it doesn't rely on PATH. So if python -m pip --version works but pip --version doesn't, that's your issue. In that case, just use python -m pip for everything. It's actually more reliable because it's tied to a specific Python version.
You're using an Anaconda or Miniconda environment
If you use Conda, don't mess with system pip. Instead, run conda install pip inside your active environment. That will install pip correctly for that environment.
My personal advice: stop using the barepipcommand. Get in the habit of typingpython -m pipevery time. It saves you from these PATH headaches and makes sure you're installing packages for the same Python you're coding with.
Once pip is back, you won't see that ModuleNotFoundError again. And if you do, you know exactly what to do: open a terminal, run python -m ensurepip --upgrade, and you're back in business.