ImportError: No module named requests
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
Popular Answer
Requests is not a built in module (does not come with the default python installation), so you will have to install it:
OSX/Linux
Use $ sudo pip install requests
(or pip3 install requests
for python3) if you have pip
installed. If pip is installed but not in your path you can use python -m pip install requests
(or python3 -m pip install requests
for python3)
Alternatively you can also use sudo easy_install -U requests
if you have easy_install
installed.
Alternatively you can use your systems package manager:
For centos: yum install python-requests
For Ubuntu: apt-get install python-requests
Windows
Use pip install requests
(or pip3 install requests
for python3) if you have pip
installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m pip install requests
(or python3 -m pip install requests
for python3)
Alternatively from a cmd prompt, use > Path\easy_install.exe requests
, where Path
is your Python*\Scripts
folder, if it was installed. (For example: C:\Python32\Scripts
)
If you manually want to add a library 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
)
From Source (Universal)
For any missing library, the source is usually available at https://pypi.python.org/pypi/. You can download requests here: https://pypi.python.org/pypi/requests
On mac osx and windows, after downloading the source zip, uncompress it and from the termiminal/cmd run python setup.py install
from the uncompressed dir.
(source)
Read more… Read less…
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
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
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
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
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