Install Python Requests With Yum

Python modules for Red Hat-based Linux operating systems like Red Hat, Fedora, Rocky Linux, and CentOS are hosted on yum repositories.

This article will show how to install and remove the Python requests module using YUM or DNF package managers. We will also discuss how to install requests using pip.

The requests package is used to send and receive HTTP requests using Python.

Installing requests using yum

The requests library can be installed on Red Hat-based Linux devices by following these steps.

Step 0: Open the terminal application and run the following command to update the yum database

Step 1: Once yum repositories are updated, we can now install requests as python-requests by running

Note: You can install python-requests similarly, using DNF package manager instead of yum. Just replace yum with dnf in the above commands.

Uninstalling requests installed with yum

If you want to uninstall requests that were installed with yum or dnf you can do that by using the command

or

Note: The yum repository contains fewer Python packages than the official Python repository – Python Packages Index (PyPI). Moreover, Python packages hosted on PyPI are generally more updated than the ones available in yum repositories (For example, by the time of writing this article, PyPI has the latest requests package being version 2.28.1, but yum has 2.27.1). For this reason, you might prefer to install requests from PyPI using pip.

Bonus: Installing requests using pip

PyPI packages can be installed using pip, but pip is not installed by default in Red Hat-based systems. You can install pip using yum or dnf from the terminal using the following command.

or

If you are running Python 2 you need to install python2-pip. Once pip is installed, you can use it to install requests in Fedora, CentOS, Rocky Linux, or RedHat by running the following on the terminal

You can update requests using pip by issuing –upgrade option (or -U shorthand) as follows

And Python requests can be removed by running