ImportError: No module named requests

6.8K    Asked by AbigailAbraham in Python , Asked on Apr 10, 2021

On importing requests, I am getting an error saying No module Named requests.

 

import requests
The error I get:
File "ex2.py", line 1, in
import requests
ImportError: No module named requests

Answered by Abigail Abraham

You are getting this error “no module named 'requests” 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 Libsite-packages folder of your python path. (For example: C:Python27Libsite-packages)



Your Answer

Interviews

Parent Categories