How to Install pip on Ubuntu

How to Install pip on Ubuntu
Install pip using sudo apt install python3-pip. This post is about this, the universe repository error you will run into, how pip vs pip3 applies here, and how to see what version you end up with.
How do I install pip on Ubuntu?
Use sudo apt install python3-pip. This will install pip for Python 3, which is the version modern Ubuntu uses.
$ sudo apt install python3-pip
This is the install command recommended in one popular Ubuntu pip guideβon a clean install, this is typically all it will take, though the next section explains how to fix if apt doesn't recognize the package.
Why do I need to enable the universe repository first?
python3-pip is found in the Ubuntu universe repository and not main. If universe isn't enabled, the command sudo apt install python3-pip won't find the package.
$ sudo add-apt-repository universe
$ sudo apt update
$ sudo apt install python3-pip
As the guide mentions explicitly, the universe repository must be enabled with sudo add-apt-repository universe to find the package β universe will be automatically enabled on most default Ubuntu installations.
Should I run pip or pip3 on Ubuntu?
Both work, but pip will run the pip3 command on modern Ubuntu systems. The command pip defaults to pip3 on Ubuntu 20.04+.
$ pip3 --version
$ pip --version
The guide says it perfectly: "pip command defaults to pip3 in Ubuntu 20.04 and above" β so, running either command should return the same version number.
How do I check which version of pip is installed?
Use pip3 --version. It will return the pip version, the location where it is installed and the version of Python it is using.
$ pip3 --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
This output format β the version number, installation location and version of Python β is exactly what the guide displays as an example, so this is useful for checking what version of pip you have and which Python version it is connected to.
How do I upgrade a package I've already installed with pip?
Use pip3 install --upgrade followed by the package name. Without the --upgrade option, pip just verifies the package is already installed.
$ pip3 install --upgrade <package-name>
This is the command used to upgrade a package according to the guideβyou will have to use this command for each package individually since the command upgrades only a single package.
All of our VPS plans and Bare Metal servers come with full access to apt and installing and managing pip on them is exactly the same as in this tutorial.
Get started with Orbit Servers
Low-latency VPS, bare metal, and colocation across the US, EU, and APAC - provisioned instantly and built for performance-critical workloads.
Get startedRelated products
Written by
Julius