ImportError: No module named requests

In Python, if you try to import Requests without installing the module using pip, you will get ImportError: no module named requests error. 

In this tutorial, let’s look at installing the Requests module correctly in different operating systems and solve no module named requests error.  

ImportError: No module named requests

Requests are not a built-in module (it doesn’t come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it.

If you are getting an error installing pip checkout pip: command not found to resolve the issue.

Install Requests in OSX/Linux 

The recommended way to install the requests module is using pip or pip3 for Python3 if you have pip installed already.

Using Python 2

$ sudo pip install requests 

Using Python 3

$ sudo pip3 install requests 

Alternatively, if you have easy_install in your system, you can install requests using the below command.

Using easy install

$ sudo easy_install -U requests

For CentOs

$ yum install python-requests

For Ubuntu

To install requests module on Debian/Ubuntu for Python2:

$ sudo apt-get install python-requests

And for Python3, the command is:

$ sudo apt-get install python3-requests

Install Requests in Windows

In the case of windows, you can use pip or pip3 based on the Python version you have to install the requests module.

$ pip3 install requests

If you have not added the pip to the environment variable path, you can run the below command in Python 3, which will install the requests module. 

$ py -m pip install requests
Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like