It is also fast and very beginner-friendly as it abstracts complex HTTP operations behind sweet and straightforward functions.
This article will discuss how to resolve the ModuleNotFound error when importing the requests library in Python.
Error Source
The ModuleNotFound error occurs when you attempt to import a non-existent module.
The requests library is not part of the Python standard library. This means you have to install it in your environment before using it.
You can do it with a simple command as shown in the instructions below:
Install Requests on Windows
On Windows, open your terminal session and run the command below:
Or
Or
The above commands should fetch the requests library and install it in your environment.
Install Requests on Linux
On Linux, use the commands as shown below for your specific distribution.
Note that you have to ensure you have the Python and Pip installed before running the commands below.
Debian-based Distros:
$ sudo pip3 install requests
You can also install requests using apt as shown in the command below:
$ sudo apt-get install python3-requests
On REHL systems, run the commands:
or
To use your package manager, run the commands:
or
With that, you should have the requests library installed in your environment.
Terminate
This article illustrated practical methods to resolve the ModuleNotFound error when importing the requests module in Python.