Rocky Linux

How to Install and Use Python PIP on Rocky Linux 9

Python PIP or the Package Installer for Python is used to install and handle the packages that are developed in Python. PIP has now become an important utility of the Python ecosystem that allows the developers to access various open-source frameworks. It was developed to fulfill the requirements to install the Python packages.

PIP is a CLI tool to simplify the installation, upgrade, and removal of Python packages from PyPI (Python Package Index). Therefore, PIP offers a convenient way to include external libraries in Python projects which makes the sharing and reusing of code simple. If you also want to install PIP on your system, this tutorial is for you. Here, we will explain the ways to install and use the Python PIP on Rocky Linux 9 (RHEL-based OS).

How to Install and Use the Python PIP on Rocky Linux 9

Make sure that you have the Python installed before installing Python PIP. If you haven’t installed it yet, run the following command to install it:

sudo dnf install python -y

You can check whether Python is successfully installed or is already present on your system by checking its version. To do this, use the following command:

python --version

You are now ready to install the Python PIP on Rocky Linux 9.

Install through the Repository

Python PIP is available in the repositories of almost all Linux distros. The repository contains it, so you can directly install it from there. For this, update the repository first using the following command:

sudo dnf update

As you can see, the installed Python version in our system is 3.9. To install the Python PIP, let’s execute the following command:

sudo dnf install python3-pip

Thus, Python PIP has been successfully installed in your Rocky Linux. Check its version to verify that it is installed:

pip3 --version

Install through the Script

Sometimes, the latest or updated version of Python PIP may not be installed through the repository. As you can see, its 21.1 version has been installed through the previous method.

Through the script, you can install the updated version of Python PIP. For this, download the script first with the help of the wget or curl command as follows:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Now, install the Python PIP with the help of the following command:

sudo python3 get-pip.py

Then, check the version of Python PIP with the following command:

pip3 --version

Now, you can see that its version is 23.1 which is its updated version.

The Use of Python PIP on Rocky Linux 9

The general syntax to use the Python PIP is as follows:

pip3 <options> <package_name>

Install a Package

In this example, we install the debug package through it, providing useful information about debugging.

pip3 install debug

Get the Detailed Information about a Specific Package

Run the following command to know the details of any installed package:

pip3 show debug

Upgrade a Package

Similarly, to upgrade any installed package with the help of Python PIP, run the following command in the terminal:

pip3 install --upgrade debug

List All Installed Packages

The following command lists all Python PIP packages:

pip3 list

Uninstall a Package

A specific package can also be uninstalled using the following command:

pip3 uninstall debug

List All Outdated Packages

You can list all the outdated packages by executing the following command:

pip3 list --outdated

Apart from this, you can explore the Python PIP options with the help of the following command:

pip3 --help

This is how you can use the Python PIP through various options.

Conclusion

This is all about the approaches that you can try to install and use Python on Rocky Linux 9 without trouble. We included multiple examples to explain the usage of Python PIP. We recommend you to download the correct package from the official website. Otherwise, you may face an error while installing the RPM package.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.