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 --versionUpgrade pip to Latest Version
Upgrade pip using itself:
python -m pip install --upgrade pip
python3 -m pip install --upgrade pipIf you encounter permission errors on Linux/macOS:
python3 -m pip install --upgrade pip --user
sudo python3 -m pip install --upgrade pipInstall pip If Missing
Using get-pip.py (Recommended)
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.pyUsing 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-pipUsing ensurepip Module
Python 3.4+ includes a pip bootstrapper:
python -m ensurepip --upgradeVirtual 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 .venvDeactivate when done:
deactivateCommon 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.txtTroubleshooting
"pip is not recognized" (Windows)
Python wasn't added to PATH during installation:
python -m pip install package_namePermission Denied (Linux/macOS)
pip install --user package_name
python -m venv .venv && source .venv/bin/activateSSL Certificate Errors
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org package_name
/Applications/Python\ 3.x/Install\ Certificates.commandMultiple Python Versions
python3.11 -m pip install package_name
python3.10 -m pip install package_name
py -3.11 -m pip install package_nameQuick 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.