Upgrade pip through the interpreter you actually use: python -m pip install --upgrade pip on Windows and python3 -m pip install --upgrade pip on macOS or Linux. Run the command inside the active virtual environment; if Linux reports an externally managed environment, use the distribution package manager or a project virtual environment instead of forcing a system-wide pip replacement.
How to Upgrade Pip in Python: Windows, macOS, and Linux
Learn exactly how to upgrade pip in Python on Windows, macOS, and Linux. Fix common 'pip not recognized' errors and manage virtual environments easily.
// The short answer
In this guide · 6 sections
You are likely here because your terminal just warned you that a new release of pip is available, or worse, you encountered an installation error due to an outdated package manager. Keeping pip updated is not just about silencing that warning; it is about ensuring compatibility with the latest Python libraries and avoiding dependency conflicts.
While the process seems simple, modern operating systems and Python configurations (like virtual environments) can make it tricky. Below is the direct, no-nonsense method to get your pip version up to date on any system.
Quick Solution (The Just Fix It Commands)
If you want to skip the details and just run the command, choose your operating system below. Run these in your terminal or command prompt:
Windows:
python -m pip install --upgrade pipmacOS / Linux:
python3 -m pip install --upgrade pipLinux (If you get an 'externally managed' error):
apt install python3-pip(Do not force pip upgrade on system Python; read the Linux section below).

Checking Your Current Version
Before making changes, it is smart to know exactly what you are running. This helps you confirm if the upgrade actually worked later. Open your terminal (or CMD on Windows) and type:
pip --versionYou will see an output similar to: pip 23.0.1 from /usr/lib/python3.10/site-packages/pip (python 3.10).
This line tells you two critical things: the pip version and the Python path it is attached to. If you have multiple Python versions installed (common on macOS and Linux), this path confirms which Python environment you are currently touching.
The Correct Way to Upgrade Pip (By OS)
Using just pip install ... can sometimes fail because of file locks or path issues. The most reliable method is executing pip as a module using python -m. This ensures the Python interpreter handles the upgrade process smoothly even if the pip script itself is being replaced.
Upgrading on Windows
On Windows, you generally have full control over your Python installation. Open Command Prompt or PowerShell and run:
python -m pip install --upgrade pipIf you see an error like Access is denied, it means your Python was installed in a system directory (like Program Files) and you are not running as an Administrator. You have two options:
Open Command Prompt as Administrator and run the command again.
Add the
--userflag to install the update only for your current user account:python -m pip install --upgrade pip --user
If Python is not recognized, you might need to check your system settings. We have a guide on how to use environment variables that can help you fix PATH issues.
Upgrading on macOS and Linux
macOS and Linux systems come with a pre-installed version of Python that the operating system uses for its own tasks. Messing with this system Python is risky.
For standard updates on your personal user profile, use python3 explicitely:
python3 -m pip install --upgrade pipCritical Warning for Linux Users (Ubuntu 23.04+ / Debian 12+): If you try to run the command above on modern Linux distributions, you will likely get an error saying error: externally-managed-environment.
This is a safety feature. It prevents you from breaking system tools that rely on the specific version of libraries shipped with your OS. Do not try to bypass this with --break-system-packages unless you know exactly what you are doing. Instead:
Use the system package manager:
sudo apt update && sudo apt install python3-pipUse pipx for global tools: If you need a Python tool globally, use
pipx.Use a Virtual Environment: For development, always create a virtual environment (see below).
If you need to locate where your Python packages are landing to clean them up manually, you can refer to our guide on how to find a directory on Linux.
How to Upgrade Pip in Virtual Environments
This is where most developers spend their time. Every virtual environment has its own isolated pip. Upgrading your global pip does not upgrade the pip inside your venv.
Standard venv / virtualenv
Activate your environment first:
Windows:
.\venv\Scripts\activatemacOS/Linux:
source venv/bin/activate
Run the upgrade command:
python -m pip install --upgrade pipYou must do this for every new virtual environment you create if you want the latest features.
Managing Pip in Conda (Anaconda / Miniconda)
If you are a Data Scientist using Conda, stop. Do not use standard pip commands to upgrade pip itself inside a Conda environment unless absolutely necessary. Mixing pip and conda package managers can break your environment.
The safe way to upgrade pip in Conda is:
conda update pipThis ensures Conda handles the dependencies and keeps your environment stable.
Troubleshooting Common Errors
Even with the right commands, things can go wrong. Here are the most frequent issues.
ModuleNotFoundError: No module named 'pip' This usually happens if the upgrade was interrupted or the pip script got deleted. You can reinstall the standard library pip using:
python -m ensurepip --default-pipPermission Errors on Windows If you see a long red error message about permissions, simply add the --user flag mentioned earlier. This installs the package to AppData/Roaming, which your user always has access to.
SSL/TLS Errors If you are on a very old machine or corporate network, pip might fail to connect to PyPI. You might need to trust the host manually (only do this if you trust your network):
python -m pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.orgHow to Downgrade Pip
Sometimes, the latest and greatest version introduces a bug or breaks compatibility with a legacy project. You can easily roll back to a specific version.
To downgrade, you just need to specify the version number:
python -m pip install pip==23.0Replace 23.0 with whatever version you need. This is a handy trick to keep in your back pocket when a new update unexpectedly breaks your workflow.
Quick answers
Frequently asked questions
What is the correct command to upgrade pip on Windows?
The safest command to upgrade pip on Windows is python -m pip install --upgrade pip. Using python -m ensures the upgrade process runs through the Python interpreter, which prevents file lock errors and ensures you are upgrading the pip version attached to your active Python environment.
How do I fix the 'pip is not recognized' error?
This error indicates that Python is not added to your system's PATH variable. To fix it, you should reinstall Python and check the box that says "Add Python to PATH" during the setup, or manually add your Python installation's Scripts folder to your Windows Environment Variables.
Why do I get an 'externally-managed-environment' error on Linux?
This error appears because modern Linux distributions (like Ubuntu 23.04+) prevent users from modifying system-wide Python packages to avoid system instability. Instead of forcing the update, you should install packages using apt (e.g., sudo apt install python3-pip) or use a virtual environment for your projects.
How can I solve 'Access is denied' when updating pip?
This permission error happens when you try to modify files in a system-protected directory without administrative privileges. You can solve this by running your Command Prompt as an Administrator or by adding the --user flag to your command: python -m pip install --upgrade pip --user.
Should I upgrade pip inside a virtual environment?
Yes, you should always upgrade pip inside every new virtual environment you create. Each virtual environment is an isolated container with its own copy of pip, so upgrading your global system pip does not automatically update the pip version inside your venv.
What is the difference between 'pip install' and 'python -m pip install'?
While both commands install packages, python -m pip is more reliable because it explicitly tells Windows exactly which Python interpreter to use. This method avoids ambiguity if you have multiple Python versions installed and prevents issues where the pip script itself gets locked during an update.
How do I downgrade pip to an older version?
To downgrade pip, you need to specify the exact version number you want to install using the == operator. For example, running python -m pip install pip==23.0 will revert your pip installation to version 23.0, which is useful if a new update causes compatibility issues.
How do I update pip if I am using Anaconda?
If you are using Anaconda or Miniconda, you should use the command conda update pip instead of the standard pip command. Using standard pip commands inside a Conda environment can cause dependency conflicts and break your environment's package management system.
Something wrong or out of date?
Tools change fast. Tell the editor what no longer works.