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

sudo yum makecache

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

sudo yum -y install python-requests

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

sudo yum remove python-requests


sudo dnf remove python-requests

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.

sudo yum -y install python3-pip


sudo dnf -y install python3-pip

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

pip install requests

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

pip install --upgrade requests

And Python requests can be removed by running

pip remove requests