Advertisement
Advertisement


ImportError: No module named requests


Question

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

import requests

The error I get:

File "ex2.py", line 1, in <module>
    import requests
ImportError: No module named requests
2020/03/24
1
598
3/24/2020 12:28:23 PM


It's not obvious to me which version of Python you are using.

If it's Python 3, a solution would be sudo pip3 install requests

2018/11/23

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

2019/04/02

This may be a liittle bit too late but this command can be run even when pip path is not set. I am using Python 3.7 running on Windows 10 and this is the command

py -m pip install requests

and you can also replace 'requests' with any other uninstalled library

2018/12/30

If you are using Ubuntu, there is need to install requests

run this command:

pip install requests

if you face permission denied error, use sudo before command:

sudo pip install requests
2015/04/17

On OSX, the command will depend on the flavour of python installation you have.

Python 2.x - Default

sudo pip install requests

Python 3.x

sudo pip3 install requests
2018/01/07