Skip to content

How to Install and Upgrade pip in Python

Learn how to check, upgrade, and install pip in Python, including troubleshooting common issues like permission errors and virtual environment best practices.

pip is Python's standard package manager, essential for installing libraries and managing dependencies. Keeping it updated ensures compatibility and access to the latest features.

Check Current pip Version

Verify pip is installed and see its version:

pip --version

python -m pip --version

Upgrade pip to Latest Version

Upgrade pip using itself:

python -m pip install --upgrade pip

python3 -m pip install --upgrade pip

If you encounter permission errors on Linux/macOS:

python3 -m pip install --upgrade pip --user

sudo python3 -m pip install --upgrade pip

Install pip If Missing

Download and run the official installer:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

Using System Package Manager

sudo apt update
sudo apt install python3-pip

sudo dnf install python3-pip

brew install python  # pip included

sudo pacman -S python-pip

Using ensurepip Module

Python 3.4+ includes a pip bootstrapper:

python -m ensurepip --upgrade

Virtual Environments (Best Practice)

Never install packages globally. Use virtual environments to isolate project dependencies:

python -m venv .venv

.venv\Scripts\activate

.venv\Scripts\Activate.ps1

source .venv/bin/activate

pip install requests  # Installed only in .venv

Deactivate when done:

deactivate

Common pip Commands

pip install requests

pip install requests==2.28.0

pip install -r requirements.txt

pip list

pip show requests

pip uninstall requests

pip freeze > requirements.txt

Troubleshooting

"pip is not recognized" (Windows)

Python wasn't added to PATH during installation:

python -m pip install package_name

Permission Denied (Linux/macOS)

pip install --user package_name

python -m venv .venv && source .venv/bin/activate

SSL Certificate Errors

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org package_name

/Applications/Python\ 3.x/Install\ Certificates.command

Multiple Python Versions

python3.11 -m pip install package_name
python3.10 -m pip install package_name

py -3.11 -m pip install package_name

Quick Reference

Task Command
Check version python -m pip --version
Upgrade pip python -m pip install --upgrade pip
Fresh install python get-pip.py
Create venv python -m venv .venv
Install package pip install package_name
List packages pip list

Summary

Always use python -m pip rather than bare pip to ensure you're targeting the correct Python installation. Keep pip updated regularly and work within virtual environments to maintain clean, isolated project dependencies. If pip is missing, use get-pip.py or your system's package manager to install it.

Navigation