ModuleNotFoundError: No Module Named ‘pip’ — Why It Happens and How to Fix It
Getting ModuleNotFoundError: no module named ‘pip’ in Python? This guide explains every cause and walks through fixes for Windows, Mac, Linux, and virtual environments with clear commands.
You try to install a Python package, run a pip command, or start a new project, and you get this instead:
ModuleNotFoundError: No module named 'pip'
Or its close variant:
/usr/bin/python3: No module named pip
The ModuleNotFoundError: no module named 'pip' error tells you that Python can’t find its own package manager in the environment you’re running. It’s one of those errors that feels like the foundation has dropped out from under you, because pip is what you use to install everything else.
This guide covers why it happens across different operating systems and environments, and gives you working commands to get pip back in every scenario.
Why pip Goes Missing
pip is Python’s package installer. Starting with Python 2.7.9 and Python 3.4, pip is included with standard Python installations. But there are several situations where it disappears or never gets installed in the first place:
- Minimal Python installs on Linux — Debian, Ubuntu, Fedora, and similar distributions often separate pip into its own package (
python3-pip) that you have to install separately. Installing Python from the OS package manager doesn’t always pull pip along with it. - Old Python versions — Python versions older than 3.4 don’t bundle pip by default.
- Broken virtual environments — If a virtual environment’s
site-packagesdirectory gets corrupted or partially deleted, pip can disappear from inside the venv while still existing in the system Python. - System upgrades — Upgrading your OS (particularly on Debian/Ubuntu when moving between major versions) can misconfigure Python’s paths and leave pip in a broken state.
- Wrong Python executable — Running
pipmight point to a different Python installation than the one you’re actually working with. Your system might have Python 3.9 and Python 3.11 installed simultaneously, and pip might belong to one but not the other. - PATH issues — pip is installed but the directory containing it isn’t in your system’s PATH, so the shell can’t find it.
Knowing which of these is your situation points you to the right fix.
Fix 1: Use ensurepip to Bootstrap pip
ensurepip is a Python standard library module designed to install pip into environments where it’s missing. This is the cleanest first fix to try in most situations.
On Linux or macOS:
python -m ensurepip --upgrade
# or
python3 -m ensurepip --upgrade
On Windows:
py -m ensurepip --upgrade
If this works, verify pip is available:
python -m pip --version
The --upgrade flag ensures you get the latest version of pip, not just the minimum bundled one. If ensurepip succeeds, you’re done. If it tells you ensurepip is disabled, you’re likely on a system-managed Python installation and need to use the OS package manager instead.
Fix 2: Install pip via the OS Package Manager (Linux)
On Debian and Ubuntu-based systems, pip is a separate package:
sudo apt update
sudo apt install python3-pip
On Fedora:
sudo dnf install python3-pip
On CentOS and RHEL:
sudo yum install python3 python3-pip
After installing, verify it works:
pip3 --version
This is often the correct fix when you’ve installed Python via apt, dnf, or yum and pip wasn’t pulled in automatically. It’s the most common scenario on fresh Linux servers and cloud instances.
Fix 3: Use get-pip.py for a Manual Reinstall
When neither ensurepip nor the OS package manager work, downloading and running the official pip installer directly is a reliable fallback.
Step 1: Download the installer script:
# On Linux/macOS
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# On Windows (if curl isn't available, download manually from https://bootstrap.pypa.io/get-pip.py)
Step 2: Run it with your Python interpreter:
# Linux/macOS
python get-pip.py
# Force reinstall if pip is partially installed but broken
python get-pip.py --force-reinstall
# Windows
py get-pip.py --force-reinstall
The --force-reinstall flag is useful when pip is technically present but in a broken state. It removes and reinstalls pip completely rather than skipping because a version already exists.
After running this, verify:
python -m pip --version
Fix 4: Reinstall Python with pip Included (Windows/macOS)
On Windows, the most reliable fix when pip is completely missing is to reinstall Python using the official installer from python.org.
During installation, make sure you:
- Check the box that says “Add Python to PATH” on the first screen
- Select “Customize installation” and ensure pip is checked in the optional features list
After reinstalling, open a new terminal and verify:
py -m pip --version
On macOS, if you installed Python via Homebrew:
brew install python3
Homebrew’s Python always includes pip. If you installed via the official macOS installer, downloading the latest from python.org and reinstalling is the clean fix.
Fix 5: Recreate a Broken Virtual Environment
If you’re getting this error inside a virtual environment rather than your system Python, the cleanest fix is to delete the broken venv and create a fresh one. Trying to repair a corrupted venv usually takes more time than starting over.
# Navigate to your project directory
cd myproject
# Delete the broken virtual environment
rm -rf .venv # Linux/macOS
rmdir /s /q .venv # Windows
# Create a fresh one
python3 -m venv .venv
# Activate it
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Upgrade pip inside the new venv
python -m pip install --upgrade pip
# Now install your project dependencies
pip install -r requirements.txt
Always run python -m pip inside an active virtual environment rather than calling pip directly. This ensures you’re using the pip that belongs to the active interpreter, not a system pip that might point somewhere else.
Python’s package ecosystem becomes much more manageable when you understand how pip and virtual environments work together. For developers expanding from basic scripts into larger projects, understanding the tools available is as important as knowing the language itself. Top 10 Python Libraries on DataWider covers the ecosystem pip gives you access to.
Fix 6: Check and Fix PATH Issues
If pip is installed but the shell can’t find it, the issue is a missing PATH entry.
On Windows: Find your Python installation path:
where python
# Example: C:\Users\YourName\AppData\Local\Programs\Python\Python311\python.exe
Then add the Scripts folder from that path to your PATH environment variable:
C:\Users\YourName\AppData\Local\Programs\Python\Python311\Scripts\
Go to: System Properties → Advanced → Environment Variables → find Path under System Variables → Edit → add the Scripts directory.
On Linux/macOS: Add pip’s location to your PATH in your shell config file (.bashrc, .zshrc, or .bash_profile):
export PATH="$HOME/.local/bin:$PATH"
Then reload:
source ~/.bashrc
After this, pip should be findable from any terminal session.
Use python -m pip as a Good Habit
Even when pip works correctly, using python -m pip instead of calling pip directly is a better habit in most situations. It guarantees that you’re using the pip associated with the specific Python interpreter you’re invoking, not a pip that might belong to a different Python version on your system.
# Instead of:
pip install requests
# Use:
python -m pip install requests
python3 -m pip install requests
This habit becomes especially important when you have multiple Python versions installed, or when working in virtual environments where the active interpreter might not match the globally accessible pip binary. It also avoids a whole category of environment confusion that tends to show up as ModuleNotFoundError errors of various kinds. Building solid Python environment habits is foundational for any kind of programming work, from web development to data science. If you’re considering where those skills lead career-wise, 5 Reasons Why Software Testing Is a Good Career Choice on DataWider gives a useful perspective on Python-adjacent technical careers.
Quick Diagnostic Steps
When you hit ModuleNotFoundError: no module named 'pip', work through this before trying any fix:
- Which Python are you running? Run
python --versionandpython3 --versionto see what’s installed. - Does pip exist anywhere? Run
which pip(Linux/macOS) orwhere pip(Windows) to see if it’s on the PATH at all. - Are you in a virtual environment? Check if your terminal prompt shows a venv name in parentheses. If it looks broken, recreate it.
- Are you on a Linux server? Try the OS package manager first (
sudo apt install python3-pip). - Did a system upgrade just happen? Force reinstall pip using
get-pip.py --force-reinstall.
Python environment issues like this are actually good to encounter early in your development journey. Understanding how pip, Python versions, and virtual environments interact is knowledge that pays off in every project you’ll work on from this point forward. The same kind of systematic debugging thinking applies when working with complex data tooling and infrastructure. Computer Vision: The Next Big Thing on DataWider is a good example of how Python’s ecosystem powers cutting-edge applications once your environment is set up correctly.
Key Takeaways
ModuleNotFoundError: no module named 'pip' means pip isn’t installed in the Python environment you’re using, or the shell can’t find it. Here’s the checklist:
- Try
python -m ensurepip --upgradefirst — it’s the fastest fix in most situations - On Linux, use your OS package manager (
sudo apt install python3-pip) - For broken pip, use
get-pip.py --force-reinstallto start fresh - On Windows/macOS, reinstall Python from python.org if everything else fails
- For broken virtual environments, delete and recreate the venv — don’t try to repair it
- Fix PATH if pip exists but isn’t findable — add the Scripts/bin directory to your environment PATH
- Use
python -m pipas a consistent habit to avoid interpreter mismatches
Get pip working first. Everything else in the Python ecosystem flows from there.