Guides 11792 Published by

The article explains how to get pip working on Ubuntu 22.04 when the package is missing after a minimal install, warning that the distro omitted it intentionally for a lean base image. It walks through a simple three‑step process: first run `sudo apt update` to refresh mirrors, then install `python3-pip` with `sudo apt install`, and finally confirm installation by checking `python3 -m pip --version`. The author also offers an optional upgrade using `sudo python3 -m pip install --upgrade pip` to bring the tool up to date for modern wheels and explains common pitfalls such as confusing `pip3` with the module form or installing inside a virtualenv before the system‑wide package. By following these steps, developers can avoid broken virtual environments and ensure that pip aligns correctly with Ubuntu’s default Python interpreter.



How to Install Python Pip on Ubuntu 22.04 LTS: Quick Fix for Missing or Broken Pip

If you’re running Ubuntu 22.04 and just can’t seem to get pip working, it’s probably because the package didn’t ship with your distro by default. The good news? Installing it is a one‑liner, but I’ll walk through why each step matters so you don’t end up chasing down broken virtualenvs later.

Why Pip Might Be Missing After an Upgrade

I’ve seen this happen after a fresh install of 22.04: the “python3‑pip” package was omitted from the minimal set, leaving developers scrambling when their `pip list` returned nothing or they got a `ModuleNotFoundError`. It’s not a bug; it’s just that Ubuntu shifted its packaging strategy to keep the base image lean.

Step 1 – Update Your Package Index
sudo apt update

Running `apt update` ensures you’re pulling from the latest mirrors. Skipping this step can lead to “Package ‘python3‑pip’ has no installation candidate” errors because your package list is stale.

Step 2 – Install pip for Python 3
sudo apt install python3-pip

The `python3-pip` package installs the official Debian/Ubuntu version of pip. It’s precompiled, signed, and guaranteed to work with the system’s default Python interpreter. If you try installing a different version via `pip install --upgrade pip`, you’ll end up with a mismatched binary that might break system scripts.

Step 3 – Verify the Installation
python3 -m pip --version

If everything went well, you should see something like `pip 22.0.4 from /usr/lib/python3/dist-packages/pip (python 3.10)`. The `-m` flag ensures you’re calling the correct interpreter’s module, which is safer than invoking a stray `pip` binary that might be shadowed by a user‑installed version.

Optional: Upgrade pip to the Latest Release
sudo python3 -m pip install --upgrade pip

This pulls the newest release from PyPI. I’ve had cases where a project required a feature only in pip 23, and the distro’s bundled 22 would refuse to install certain wheels. Upgrading guarantees compatibility with modern packaging standards.

Common Pitfalls
  • Using `pip3` instead of `python3 -m pip` – The symlink `pip3` can point to an older or broken executable if you have multiple Python installations. Stick with the module invocation.
  • Installing inside a virtualenv before system‑wide pip – If you create a venv and try `pip install`, it will use whatever version is in your environment, which might be out of date. After installing system‑wide pip, recreate any venvs to inherit the new binary.
Quick Recap

1. Update apt’s cache.
2. Install `python3-pip`.
3. Confirm with `python3 -m pip --version`.
4. (Optional) Upgrade to the latest pip release.

That’s all you need to get a working pip on Ubuntu 22.04 LTS.