How to install python2-requests rpm in Rocky Linux 9?

Hi, I have installed python2 in Rocky Linux 9 from https://rhel.pkgs.org/9/raven-x86_64/
Now, i want to install python2-requests rpm for my project. Can anyone help how to get this rpm and install it in Rocky Linux 9?

I suppose the best way will be

pip install requests==2.27.1

2.27.1 is the latest version with Python 2 support

Since pip is not installed by default:

dnf install python3-pip

will provide the pip binary.

I’m also going to suggest following @rzmv’s suggestion inside a Python Virtual Environment. Otherwise I would suggest a slightly modified version of the pip command:

pip install --user requests==2.27.1

TL;DR Reasoning

Python pip is intentionally left off RHEL (hence downstream too) as Python packages/modules are primarily intended to be installed via RPM. Installing pip is possible and installing packages via pip works. However if not using a Python virtual environment (venv) and pip applies changes to the systems Python lib it can lead to issues during upgrades or using other Python scripts or modules.

Adding the --user flag will create ~/.local/lib for the local user executing pip. This should avoid most conflicts from using pip while the system is managing Python via RPM.

Thanks. I am already having ‘requests’ package with version 2.25.1 but when I’m trying to import requests, I’m getting ImportError.

I have Python 2.7.17 in my machine.

import requests
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named requests

exit()

Thanks. I am already having ‘requests’ package with version 2.25.1 but when I’m trying to import requests, I’m getting ModuleError.

I have Python 2.7.17 in my machine.

import requests
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named requests

exit()

Since OP installed python2 from the 3rd-party repo, I believe the command to install pip should be

dnf install python2-pip

to also install pip from the mentioned 3rd-party repo

https://rhel.pkgs.org/9/raven-x86_64/python2-pip-9.0.3-19.el9.noarch.rpm.html

We need more information on how you had installed requests package.

Thanks. I started with the --user comment, but decided at the end to add the installation as a first step. Then used the systems default version… :person_facepalming: