Why This Happens
You upgraded Python—maybe from 3.10 to 3.12—and suddenly pip is missing. This is common. The new Python version doesn't automatically bring its own pip, especially if you installed it from a source like python.org or a package manager that strips it out.
The error shows up when you run pip install something or python -m pip. You'll see something like:
ModuleNotFoundError: No module named 'pip'Don't panic. You don't need to reinstall Python. Here's the fix, starting with the quickest option.
Fix 1: The 30-Second Try
First, check if pip is just hidden. Sometimes the upgrade leaves pip behind but not on your PATH. Run this:
python -m pip --versionIf that shows a version number, then pip exists—you just need to invoke it with python -m pip instead of pip.
If you see the error again, move to Fix 2.
Fix 2: Use ensurepip (5 Minutes)
Python ships with a tool called ensurepip. It can install pip into your current Python environment. This is the standard, safe way to get pip back.
On Windows, macOS, or Linux
- Open your command prompt or terminal.
- Run this command:
python -m ensurepip --upgradeWhat to expect: After running it, you'll see some output like Successfully installed pip-23.2.1 (version may vary).
Now test it:
python -m pip --versionIf that works, you're done. If not, or if you get an error like No module named ensurepip, move to Fix 3.
Fix 3: Manual Install with get-pip.py (15+ Minutes)
When ensurepip is missing—which happens if your Python build didn't include it—you'll need to grab pip from the official source. This takes a few extra steps but works every time.
Step 1: Download get-pip.py
Open a browser and go to:
https://bootstrap.pypa.io/get-pip.pyRight-click and save the file as get-pip.py in your home directory or any folder you can find easily.
Step 2: Run the Installer
Open a terminal (or command prompt) and cd to the folder where you saved the file. Then run:
python get-pip.pyWhat to expect: The script will download pip and install it. You'll see progress bars and a final message. It might also try to upgrade setuptools and wheel—that's fine, let it do its thing.
Step 3: Verify pip
python -m pip --versionYou should see something like pip 23.2.1 from /usr/local/lib/python3.12/site-packages/pip (python 3.12). That means pip is installed and working.
Step 4: Add pip to PATH (if needed)
If you want to use just pip instead of python -m pip, you might need to add the Scripts folder to your PATH. This is common on Windows.
To find the Scripts folder, run:
python -m site --user-siteThat prints a path like C:\Users\YourName\AppData\Roaming\Python\Python312\site-packages. Go up one level and you'll see a Scripts folder. Add that to your system PATH.
I'm not going to detail PATH editing here because it varies by OS. Search for your OS and 'edit PATH' and you'll get exact steps.
What If You're Using a Virtual Environment?
If you're in a virtual environment (venv) and pip is missing, the same fixes apply, but run them while the env is activated. The python command inside the env points to that env's interpreter.
If you just upgraded Python globally, your existing venvs might be broken. That's a separate issue—you'd need to recreate them with python -m venv myenv.
Prevent This Next Time
When you upgrade Python in the future, check if pip comes along. After the upgrade, run python -m pip --version right away. If it's missing, use ensurepip immediately—it's the fastest fix.
Also, if you use package managers like Homebrew or apt, they sometimes handle pip separately. For Homebrew, you'd do brew install python-pip. For apt, sudo apt install python3-pip. But the manual method above works regardless.
One more thing: don't use sudo pip install on Linux if you can avoid it. Use a virtual environment. It saves you from a world of pain later.
That's it. You should have pip back now. If you hit any snags, the official pip documentation at pip.pypa.io has the full details.