How to Install Python Pip on Ubuntu

Pip (Pip Installs Packages) is Python’s package manager. You can use it to install, upgrade, or remove Python packages from the Python Package Index (PyPI) and other sources.
This guide covers installing pip for Python 3 on Ubuntu, verifying the installation, and using it safely in your projects.
Supported Ubuntu Versions
These instructions apply to all current Ubuntu LTS releases, including:
- Ubuntu 24.04 LTS (Noble)
- Ubuntu 22.04 LTS (Jammy)
- Ubuntu 20.04 LTS (Focal)
Before You Begin
Python 3 is included in the base system installation. Ubuntu no longer ships Python 2, which has reached end of life. If you must run legacy Python 2 code, consider using a container or a dedicated legacy environment.
Python modules can be installed globally (accessible for all projects and users) or on a project basis.
Generally, when installing a Python module globally, you should prefer installing the module’s deb package with apt
, as these packages are tested to work properly on Ubuntu systems. Use pip to install a module globally only if there is no deb package for that module.
Avoid running pip with sudo outside of a virtual environment. If you need a per-user install without a virtual environment, add the --user flag.
Packages for Python 3 usually start with python3- in their names.
Use pip inside a virtual environment for project work. Virtual environments let you install Python modules for a single project without affecting other projects or your system’s Python setup.
Installing pip for Python 3 (System-Wide)
This section describes how to install pip system-wide. For project work, install packages inside a virtual environment to avoid conflicts.
Installing pip for Python 3 on Ubuntu is straightforward. Run the following commands as root or a sudo user in your terminal:
sudo apt update
sudo apt install python3-pipThis command installs pip and its standard Ubuntu package dependencies. Some Python packages with native extensions may still require additional system packages.
Once the installation is complete, verify it by checking the pip version:
pip3 --versionThe version number you see might be different, but it should look similar to this:
pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12)If you prefer to be explicit about the Python interpreter, use:
python3 -m pip --versionUsing Pip in a Virtual Environment (Recommended)
Using pip in a virtual environment keeps your system Python clean and prevents conflicts. For a full walkthrough of creating and managing virtual environments, see Python Virtual Environments: venv and virtualenv
. If you do not have venv yet, install it with:
sudo apt update
sudo apt install python3-venvCreate a virtual environment in your project directory:
python3 -m venv .venvActivate it and upgrade pip inside the environment:
source .venv/bin/activate
python -m pip install --upgrade pipYour prompt will show the active environment name. To exit it, run:
deactivateCommon Pip Commands
Here are a few common pip commands you will use inside a virtual environment:
externally-managed-environment error. Activate a virtual environment first, then run the pip commands below.pip3 --help
Installing Packages with Pip
The most basic function of the pip tool is to install a package. To install the latest version of a package, run:
pip3 install package_nameFor example, to install NumPy:
pip3 install numpyTo install a specific version of a package, append == and the version number after the package name:
pip3 install numpy==1.26.4Installing Packages with Pip Using the Requirements File
requirements.txt is a text file containing a list of pip packages and their required versions for a specific Python project.
To install a list of requirements specified in a file, use the following command:
pip3 install -r requirements.txtListing Installed Packages
To list all the installed pip packages, use the “list” subcommand:
pip3 listUpgrade a Package With Pip
To upgrade an installed package to the latest version, enter:
pip3 install --upgrade package_nameUninstalling Packages With Pip
To uninstall a package, run:
pip3 uninstall package_nameTo get help for a specific pip command, use:
pip3 command --helpPython 2 (Not Supported)
Python 2 and pip2 are no longer available in Ubuntu repositories. If you need Python 2 for legacy applications, run it in a container or use a dedicated legacy VM.
Conclusion
We have covered how to install pip for Python 3 on Ubuntu and the basic commands for managing packages. While you can install packages globally, using virtual environments is the recommended practice for project development.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page