Ubuntu

How to Install Python pip on Ubuntu 22.04

Python is one of the most widely utilized high-level languages, with applications ranging from simple scripts to complicated machine learning algorithms, and Pip is a Python package installation utility that is used for searching, downloading, and installing packages from the Python Package Index (PyPI).

Python is available in two versions: Python2 and Python3. Python3 is included in the Ubuntu 22.04 official repository. However, Python2 can be installed using the “universerepository.

This write-up will discuss the procedure to install Python3 pip and Python2 pip on Ubuntu 22.04. So, let’s start!

How to install Python3 pip on Ubuntu 22.04

To install Python3 pip on Ubuntu 22.04, you must follow the below-given step-by-step instructions.

Step 1: Update system repositories

Press “CTRL+ALT+T” to open the terminal of the Ubuntu 22.04 and run the below-given command to update system repositories:

$ sudo apt update

Step 2: Install Python3 pip on Ubuntu 22.04

After updating the system repositories, execute the following command for the installation of Python3 pip on Ubuntu 22.04:

$ sudo apt install python3-pip

Type “y” to allow the ongoing installation to continue:

The above-given error-free output declares that now the Python3 pip is all set up on our Ubuntu 22.04 system.

Step 3: Verify Python3 pip version

To validate the existence of Python3 pip on your system, execute the “pip3” command with the “–version” command:

$ pip3 --version

Step 4: View Python3 pip manual

Want to get more knowledge about Python3 pip, its options, commands, and syntax? Check out its user manual with the help of the following command:

$ pip3 --help

Now, let’s have a look at the other method of the Python pip installation.

How to install Python2 pip on Ubuntu 22.04

As a Linux user, it is important for you to know that the default repository does not include pip for Python2. So, to utilize it on your system, enable the “universe” repository.

Step 1: Enable universe repository

For the purpose of enabling the “universe” repository on Ubuntu 22.04, write out the following command:

$ sudo add-apt-repository universe

Step 2: Install Python2 on Ubuntu 22.04

In the next step, you have to install Python2 with the help of the below-given command:

$ sudo apt install python2

Wait for a few minutes as the Python2 installation will take some time:

Step 3: Download Python2 pip script

Then, execute the following “curl” command to download the pip script:

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

Step 4: Install Python2 pip script

If you have carefully followed the previous given step, then at this point, your system is all ready for the installation of Python2 pip:

$ sudo python2 get-pip.py

As you can see from the output, we have successfully installed Python2 pip along with its “wheel” and “setuptools”:

Step 5: Check Python2 pip version

In order to check the version of the installed Python2 pip version, write out the given command in your Ubuntu 22.04 terminal:

$ pip2 version

Step 6: View Python2 pip manual

To get more knowledge about Python2 pip, its options, commands, and syntax, check out its user manual with the help of the following command:

$ pip2 --help

We have compiled the methods to install Python3 pip and Python2 pip on Ubuntu 22.04. You can further research as needed.

Conclusion

For the installation of Python3 pip on Ubuntu 22.04, you can execute the “$ sudo apt install python3-pip” command, whereas for Python2 pip, firstly enable the “universe” repository, then download the pip script with the “$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py –output get-pip.py” curl command. After that, utilize the “$ sudo python2 get-pip.py” command. This write-up discussed the install Python3 pip and Python2 pip on Ubuntu 22.04.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.