ModuleNotFoundError: No module named 'pip'

Fix pip Missing After Python Upgrade on Windows and macOS

After upgrading Python, pip disappears. This guide shows you two reliable fixes: the built-in ensurepip tool and the get-pip.py script. Both work on Windows and macOS.

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.

  1. Open a terminal or command prompt. On Windows, press Win + R, type cmd, and hit Enter. On macOS, open Terminal from Applications > Utilities.
  2. Check your Python version first. Type python --version and press Enter. You should see something like Python 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.
  3. Run ensurepip. Type this and press Enter:
    python -m ensurepip --upgrade

    On macOS, you might need to use python3 instead of python if your system only recognizes python3. Same command, just swap the word.

  4. Wait for it to finish. You should see output like Looking in links: ... and then Successfully installed pip-XX.X. That means it worked.
  5. Verify pip works. Type pip --version and press Enter. If it shows a version number, you're good. If it says pip is not recognized or command not found, don't panic—the module is installed, but the pip executable might not be on your PATH. Try python -m pip --version instead. 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.

  1. 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.
  2. 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.
  3. Run the script. Type this and press Enter:
    python get-pip.py

    Again, if you're on macOS or your system uses python3, use that instead.

  4. Watch the output. You should see it download pip, then install it, and finally print Successfully installed pip-XX.X. That's your confirmation.
  5. Test pip. Run pip --version or python -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 bare pip command. Get in the habit of typing python -m pip every 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.

Related Errors in Programming & Dev Tools
java.lang.OutOfMemoryError: Java heap space Fix Java OutOfMemoryError: Java heap space 0XC0000048 STATUS_PORT_ALREADY_SET (0XC0000048) – Fix the WSL/Hyper-V Port Conflict dyld: Library not loaded Fix 'dyld: Library not loaded' Ruby error on macOS after update 0XC0150014 STATUS_SXS_CORRUPT_ACTIVATION_STACK (0XC0150014) Fix

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.