How to Install Python Pip on Ubuntu 22.04

Python and other high-level programming languages are used to build websites, automate procedures, and analyze data. Pip is used as a Python package manager for downloading, searching, and updating packages from the Python Package Index (PyPI).

This post will demonstrate multiple methods to install Python Pip on Ubuntu 22.04.

The post’s content is as follows:

Let’s start with the first method:

Method 1: Installing Python3 Pip on Ubuntu 22.04

Top 10 Linux Distros

In this section, the Python3 Pip will be installed on Ubuntu 22.04. Following instructions will install python3 pip on Ubuntu.

Step 1: Update the System Repositories

First, update the system to ensure the package list is up to date. To update, run the below command:

$ sudo apt update

Step 2: Install Python Pip3 on Ubuntu 22.04

Now, install the Python3 pip on Ubuntu 22.04 by running the below command:

$ sudo apt install python3-pip -y

It will take a few seconds to install and will show the below output.

Step 3: Verify Python Pip3 Version

We can check the installed version of Python pip3 executing the below command:

pip3 --version

The output shows that the pip3 version 22.0.02 is installed on the system.

Method 2: Installing Python2 Pip on Ubuntu 22.04

In this method, Downloading and set up the Python2 pip step-by-step. Python2 pip does not come in the default repository as in Python3. To install Python2 pip on Ubuntu 22.04, follow these steps:

Step 1: Update System Repositories

Before installing Python2, first, we need to update the core libraries using the below command:

$ sudo apt update

Step 2: Install Python2 on Ubuntu 22.04

In this step, we will install Python2 using the below-mentioned command:

sudo apt install python2

Press “Y” when asked to continue the installation.

The error-free output shows Python2 is installed on Ubuntu 22.04.

Step 3: Download Python2 pip

Download pip to install, uninstall, download, and other features of Python2. To install Python2 pip, run the below-given “Curl” command:

$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

Warning: If you have not downloaded the ”Curl” package before, you will get below error while installing curl command.

Need to install the “Curl” package first by running the below command:

$ sudo apt install curl -y

The curl package is downloaded now; let’s move to the “Curl” command for installing Python2 pip.

$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

As the output suggests, the Python2 pip is downloaded.

Step 4: Install Python2 pip

Now, the system is ready to install python2 Pip on Ubuntu 22.04; install Pip by executing the below command:

$ sudo python2 get-pip.py

Output shows the successful installation of pip, along with setup tools and wheel.

Step 5: Check Python2 pip version

To check the installed version of Python Pip2, run the following command:

$ pip2 -version

Python pip2 version 20.3.4 is successfully installed.

How to Uninstall Python3 Pip from Ubuntu 22.04?

Use the below command to uninstall the Python3 pip:

$ sudo apt autoremove python3-pip

Now, the installed Python3 is removed from the system.

How to Uninstall Python2 Pip from Ubuntu 22.04?

We can remove Python2 pip from Ubuntu 22.04 by executing the below command:

$ sudo python2 -m pip uninstall pip

As the output shows, it has successfully uninstalled the Python2 pip.

That’s it from this tutorial.

Conclusion

Pip is a package manager for python that is installed in Python3 on Ubuntu 22.04 using the “$ sudo apt install python3-pip -y” command. Moreover, pip in Python2 is downloaded using “$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py –output get-pip.py” command and installed using the “$ sudo python2 get-pip.py” command. In this guide, a step-by-step guide to installing python-pip on Ubuntu 22.04 is provided.