When using Python, ModuleNotFoundError: no module named ‘requests’ is an error many people may encounter. This article will present the procedure to fix this error for your operating system.
ModuleNotFoundError: no module named ‘requests’
The ‘request’ module is an HTTP library for Python. ‘request’ module allow users to send HTTP/1.1 requests easily. Then you won’t need to put query and query strings in your URLs manually. The ‘request’ module are not automatically installed on Python. So the error ModuleNotFoundError: No module named ‘requests’ appears when you don’t have ‘request’ module installed, or it was placed in the incorrect environment before import.
Code:
import request
Output:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import request
ModuleNotFoundError: No module named 'request'
To fix the ModuleNotFoundError: No module named ‘requests’ error, all you need to do is install ‘request’ module.
The ways to install requests
Windows
First, you must have Python and pip installed on your computer, preferably the latest version of Python and pip.
To install ‘request’ module using pip, open a command prompt and run the following command:
pip3 install requests
The ‘request’ library is downloaded successfully.
Linux
Python is installed by default on most Linux distributions. But you need to install pip. Pip can be installed from the terminal. However, the method of installing pip has different syntaxes between Linux distributions. To install pip, you need to have root privileges, then open a terminal and use the commands with the correct syntax for the Linux distribution you are using.
Following is the pip installation syntax of some popular Linux distributions:
- Debian, Linux Mint, and Ubuntu
sudo apt install python-pip3
- Fedora, CentOS 8 (and newer) and Red Hat
sudo dnf install python-pip3
- Older versions of Red Hat and CentOS 6 and 7
sudo yum install epel-release
sudo yum install python-pip3
- Manjaro and Arch Linux
sudo pacman -S python-pip
- OpenSUSE
sudo zypper python3-pip
Now, you can install ‘request’ module by run this code:
pip3 install requests
MacOS
The following curl
command will make it possible to download pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
This curl
command allows you to download pip using a specified direct link. In this curl
command, the -o
option is used to name the download file.
Install pip by running:
python3 get-pip.py
Install ‘request’ from the terminal:
pip3 install requests
Alternative common method
The last method for installing ‘request’ on any operating system is to grab the base files and install ‘request’ manually. The ‘request’ module are actively developed on GitHub, where the code is always available. For code, visit here.
You can clone the public repository:
git clone git://github.com/psf/requests.git
Or, download the tarball:
curl -OL https://github.com/psf/requests/tarball/master
Once you have a copy of the source, you can embed it in your Python package or install it into your site-packages easily:
cd requests
pip install
Summary
This article has shown the cause and how to fix the ModuleNotFoundError: No module named ‘requests’ error in Python. I hope the information in this article was helpful to you.
Maybe you are interested in similar errors:
- TypeError: ‘<‘ not supported between instances of ‘str’ and ‘int’
- UnicodeDecodeError: ‘ascii’ codec can’t decode byte
- AttributeError: ‘str’ object has no attribute ‘read’
- ModuleNotFoundError: No module named ‘scipy’ in Python
- ModuleNotFoundError: No module named ‘tensorflow’ in python
- ModuleNotFoundError: No module named ‘scipy’ in Python

Hello, my name’s Bruce Warren. You can call me Bruce. I’m interested in programming languages, so I am here to share my knowledge of programming languages with you, especially knowledge of C, C++, Java, JS, PHP.
Name of the university: KMA
Major: ATTT
Programming Languages: C, C++, Java, JS, PHP