How to Install Python Pip on Ubuntu 26.04, 24.04 and 22.04

Last updated Tuesday, March 24, 2026 10:33 am Joshua James 6 min read

Standard Ubuntu desktop installs already ship Python, but pip is what turns that interpreter into something you can use for project dependencies, quick library installs, and repeatable requirements files. If you need to install Python pip on Ubuntu, the package is available through APT on Ubuntu 26.04, 24.04, and 22.04, while minimal cloud images or containers may also need the base python3 package first.

Ubuntu 24.04 and 26.04 also block both normal and --user installs outside a virtual environment, while Ubuntu 22.04 still allows per-user installs. Using the same venv-first workflow across all three releases keeps package management predictable and avoids the system Python conflicts that usually cause trouble later.

Install Python pip on Ubuntu

Install Python pip on Ubuntu with the python3-pip package from Ubuntu’s repositories. Each supported Ubuntu LTS release ships a different default Python and pip version, and the outside-venv behavior changes with it.

Ubuntu releaseDefault PythonDefault pipOutside-venv behavior
26.04Python 3.14pip 25.1.1PEP 668 blocks both normal and --user installs
24.04Python 3.12pip 24.0PEP 668 blocks both normal and --user installs
22.04Python 3.10pip 22.0.2Plain installs fall back to the user site, and --user still works

Start by refreshing the package index on your Ubuntu system:

sudo apt update

These commands use sudo for package-management tasks. If your account does not have administrative access yet, follow the guide on add a new user to sudoers on Ubuntu before you continue.

Install pip and the virtual environment module together so the recommended venv workflow is ready right away:

sudo apt install python3-pip python3-venv

Ubuntu serves python3-pip from the Universe component. If APT reports that it cannot find the package on a minimal image or cloud host, enable Universe and Multiverse in Ubuntu, then rerun the install command.

Verify that pip is installed and attached to the Python version your release ships by default:

python3 -m pip --version
pip 25.1.1 from /usr/lib/python3/dist-packages/pip (python 3.14)

On Ubuntu 24.04, the same command reports pip 24.0 with Python 3.12. On Ubuntu 22.04, it reports pip 22.0.2 with Python 3.10. The command format stays the same across supported LTS releases even though the version string changes.

Use Python pip in virtual environments on Ubuntu

Virtual environments are the cleanest pip workflow on every supported Ubuntu LTS release. They are mandatory for most non-Debian Python packages on Ubuntu 24.04 and 26.04 because PEP 668 blocks outside-venv installs, and they are still the safer habit on Ubuntu 22.04 because each project keeps its own dependency set.

If you want the full workflow in more detail, read how to create a Python virtual environment on Ubuntu. If a project needs a newer interpreter before you build the venv, install Python 3.13 with the guide on install Python 3.13 on Ubuntu, then create the environment with that interpreter.

Create a virtual environment for Python pip

Create the environment in your home directory so you can reuse it for one project without touching the system Python packages:

python3 -m venv ~/venvs/project

Activate the environment before you run any pip commands inside it:

source ~/venvs/project/bin/activate

Once the shell is active, confirm that pip now points at the environment instead of Ubuntu’s system path:

python -m pip --version
pip 25.1.1 from /home/linuxcapable/venvs/project/lib/python3.14/site-packages/pip (python 3.14)

The path changes from /usr/lib/python3/dist-packages to your venv directory, which is how you know new installs will stay isolated from the Ubuntu-managed Python packages.

Use common Python pip commands on Ubuntu

After activation, use python -m pip. If you are working against Ubuntu’s system interpreter instead, use the same commands with python3 -m pip.

Install packages with Python pip on Ubuntu

Install a package from PyPI by naming it after python -m pip install. The example below installs the widely used requests library:

python -m pip install requests

Check the package metadata after the install to confirm the version, location, and dependencies:

python -m pip show requests
Name: requests
Version: 2.32.5
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache-2.0
Location: /home/linuxcapable/venvs/project/lib/python3.14/site-packages
Requires: certifi, charset_normalizer, idna, urllib3
Required-by:

The Location field is especially useful when you are checking whether a package landed inside the active venv or somewhere else on the system.

List installed packages with Python pip on Ubuntu

List the current environment whenever you want a quick inventory of what pip installed:

python -m pip list
Package            Version
------------------ ---------
certifi            2026.2.25
charset-normalizer 3.4.6
idna               3.11
pip                25.1.1
requests           2.32.5
urllib3            2.6.3

This output is also a fast way to confirm that pip pulled in the dependency chain a package needs instead of installing only the top-level library.

Pin versions with Python pip on Ubuntu

Pin a package when a project depends on one specific release and you do not want pip to pull in a newer branch automatically:

python -m pip install requests==2.28.0
Collecting requests==2.28.0
  Using cached requests-2.28.0-py3-none-any.whl.metadata (4.6 kB)
Collecting charset-normalizer~=2.0.0 (from requests==2.28.0)
  Using cached charset_normalizer-2.0.12-py3-none-any.whl.metadata (11 kB)
Requirement already satisfied: idna<4,>=2.5 in ./pip-article-test/lib/python3.14/site-packages (from requests==2.28.0) (3.11)
Collecting urllib3<1.27,>=1.21.1 (from requests==2.28.0)
  Using cached urllib3-1.26.20-py2.py3-none-any.whl.metadata (50 kB)
Requirement already satisfied: certifi>=2017.4.17 in ./pip-article-test/lib/python3.14/site-packages (from requests==2.28.0) (2026.2.25)
Installing collected packages: urllib3, charset-normalizer, requests
Successfully installed charset-normalizer-2.0.12 requests-2.28.0 urllib3-1.26.20

Use the same pattern for any pinned dependency. Replace requests==2.28.0 with the package and exact version your project needs.

Check outdated packages with Python pip on Ubuntu

Review outdated packages before you upgrade them so you can see which installed version is behind and how far the latest release moved ahead:

python -m pip list --outdated
Package            Version Latest Type
------------------ ------- ------ -----
charset-normalizer 2.0.12  3.4.6  wheel
pip                25.1.1  26.0.1 wheel
requests           2.28.0  2.32.5 wheel
urllib3            1.26.20 2.6.3  wheel

When you are ready to update one package, use python -m pip install --upgrade package_name. That leaves the rest of the environment untouched while you move only the package you selected.

Export requirements with Python pip on Ubuntu

Freeze the environment into a requirements file when you want another system, teammate, or CI runner to recreate the same dependency set:

python -m pip freeze
certifi==2026.2.25
charset-normalizer==2.0.12
idna==3.11
requests==2.28.0
urllib3==1.26.20

Redirect that output into a file with python -m pip freeze > requirements.txt, then recreate it later with python -m pip install -r requirements.txt.

Troubleshoot Python pip on Ubuntu

Most pip problems on Ubuntu come down to one of three issues: PEP 668 blocking installs, shell commands resolving to the wrong pip binary, or using a per-user install on a release where Ubuntu now forbids it.

Fix the externally-managed-environment error for Python pip on Ubuntu

Ubuntu 24.04 and 26.04 protect the system Python environment with PEP 668, so pip stops outside-venv installs before they can overwrite files APT manages:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install python3-xyz

That restriction applies to both python3 -m pip install package_name and python3 -m pip install --user package_name on Ubuntu 24.04 and 26.04. Ubuntu 22.04 still allows --user installs, but the most reliable cross-release fix is the same everywhere: create a virtual environment, activate it, and rerun the install there.

python3 -m venv ~/venvs/project
source ~/venvs/project/bin/activate
python -m pip install package_name

If the package also exists in Ubuntu’s repositories, prefer sudo apt install python3-packagename for system-wide use. That keeps Ubuntu’s package database and the Python files it owns in sync.

Fix the pip or pip3 command not found error on Ubuntu

After you install python3-pip, Ubuntu places both pip and pip3 in /usr/bin. If your shell still says one of those commands is missing, confirm the paths directly and fall back to python3 -m pip, which works even when your shell cache has not refreshed yet.

command -v pip
command -v pip3
python3 -m pip --version
/usr/bin/pip
/usr/bin/pip3
pip 25.1.1 from /usr/lib/python3/dist-packages/pip (python 3.14)

On Ubuntu 24.04 and 22.04, the two command paths stay the same but the pip version line changes with the release. For scripts and documentation, python3 -m pip is still the clearest form because it names the interpreter explicitly.

Remove Python pip from Ubuntu

Remove the Ubuntu package only when you no longer need pip from the system interpreter. Most readers can leave the package installed and simply delete old virtual environments as projects expire.

sudo apt remove --autoremove python3-pip

Review APT’s removal list before you confirm the transaction. On development machines, --autoremove can also remove related helpers such as python3-setuptools or python3-wheel if nothing else still depends on them.

If you only want to clear one project environment, remove that directory instead of touching the system package:

rm -rf ~/venvs/project

Deleting a virtual environment removes the project-specific interpreter, pip executable, and installed packages inside that environment, but it does not affect Ubuntu’s system Python packages.

Check the package state after removal with APT:

apt-cache policy python3-pip
python3-pip:
  Installed: (none)
  Candidate: 24.0+dfsg-1ubuntu1.3

Ubuntu 26.04 shows the same layout with a newer candidate version, 25.1.1+dfsg-1ubuntu2. The important part is the Installed: (none) line, which confirms the package is gone.

Python pip on Ubuntu FAQ

What is the difference between pip, pip3, and python3 -m pip on Ubuntu?

After you install python3-pip, Ubuntu usually provides both pip and pip3 wrappers for the default Python 3 interpreter. python3 -m pip is still the clearest form because it ties pip to that interpreter even if your shell path, aliases, or virtual environment state change.

Does pip install –user still work on Ubuntu 24.04 or 26.04?

No. Ubuntu 24.04 and 26.04 block both normal and --user installs outside a virtual environment because of PEP 668. Ubuntu 22.04 still allows --user installs, but a virtual environment is the cleaner cross-release workflow.

Do I need to install Python before I install pip on Ubuntu?

Usually no. Standard Ubuntu desktop installs already include Python 3, so you normally only need python3-pip and python3-venv. Minimal cloud images, containers, and stripped-down server builds can omit Python, so check python3 --version first if you are not sure.

Is Ubuntu 20.04 still supported for Python pip on Ubuntu?

No. LinuxCapable’s current Ubuntu scope for the Python pip workflow is Ubuntu 26.04, 24.04, and 22.04. Ubuntu 20.04 left standard support in 2025, so the article stays focused on the supported LTS releases that LinuxCapable still validates.

Conclusion

Python pip is installed on Ubuntu and ready for package work, but the smoother long-term setup is building each project inside its own virtual environment instead of leaning on the system interpreter. That keeps Ubuntu’s Python packages stable, gives you repeatable requirements files, and makes it much easier to swap interpreter branches later when a project outgrows the distro default.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: