Explore Courses Blog Tutorials Interview Questions
+1 vote
in Python by (47.6k points)

Whenever I try to import requests, I get an error saying No module Named requests.

import requests

The error I get:

File "", line 1, in <module>

import requests

ImportError: No module named requests

1 Answer

0 votes
by (106k points)

You are getting this error because you have not installed the request module. Because requests are not a built in module (it does not come with the default python installation), so you will have to install it in order to run it properly.

Installation steps for OSX/Linux:-

If you have pip installed in your system use

$ sudo pip install requests 

An alternative way is also there for that you can also use if you have easy_install installed.

sudo easy_install -U requests

For centos you can use: 

yum install python-requests

In Windows you can install it by as follows:-

If in your system pip is installed and you have added pip.exe to the Path Environment Variable. You can use:-

pip install requests 

For adding the library manually to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages folder of your python path. (For example: C:\Python27\Lib\site-packages)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 29, 2020 in Python by ashely (50.2k points)

Browse Categories