Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named 'requests'. But 'requests' already installed

Trying to import 'requests'.

Has it installed via pip3 install requests? But still, have this error.

C:\Users\Vikentiy>pip3 list
Package    Version
---------- ----------
certifi    2018.11.29
chardet    3.0.4
Django     2.1.7
idna       2.8
pip        19.0.2
pytz       2018.9
requests   2.21.0
setuptools 40.6.2
simplejson 3.16.0
urllib3    1.24.1
virtualenv 16.4.0

C:\Users\Vikentiy>python --version
Python 3.7.2

Error Traceback:

C:\Users\Vikentiy\untitled2\venv\Scripts\python.exe C:/Users/Vikentiy/untitled2/requeststests.py 
Traceback (most recent call last): 
File "C:/Users/Vikentiy/untitled2/requeststests.py", line 1, in <module> import requests`
like image 682
vikentii Avatar asked Feb 17 '19 08:02

vikentii


People also ask

How do I fix ModuleNotFoundError No module named requests?

The Python "ModuleNotFoundError: No module named 'requests'" occurs when we forget to install the requests module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install requests command.

Why am I getting ModuleNotFoundError No module named?

Here are a few reasons why a module may not be found: you do not have the module you tried importing installed on your computer. you spelled a module incorrectly (which still links back to the previous point, that the misspelled module is not installed)...for example, spelling numpy as numpys during import.

Is Python requests installed by default?

The most likely reason is that Python doesn't provide requests in its standard library. This means that requests module is not a built in module and it does not come with the default python installation. So, you need to install requests module using Python's package manager "pip".

Is requests built in Python?

Requests is one of the most popular Python libraries that is not included with Python.


2 Answers

If you're using PyCharm as IDE, try closing and restarting PyCharm. Move the mouse cursor over the "requests" (with red curly line beneath it), until the red light bulb next to it show up. Select the first option in it, "Install package requests". PyCharm will take care of the installation from there.

I ran into the same issue and have tried all the solutions here on Stack Overflow.

like image 127
Egret Avatar answered Oct 22 '22 10:10

Egret


That's the exact solution which works for me, please follow this:

As like, first try to get the version of the requests module installed previously, this can be find by

pip install requests

Now, you will get the message:

Requirement already satisfied: requests in /opt/anaconda3/lib/python3.8/site-packages (2.24.0)

See, here the version of the requests module i.e., (2.24.0)

Now, the simple basic logic is this like you should install just the previous version of the requests (2.24.0). So, you should now install requests (2.20.0)

For this use command:

pip install requests==2.20.0

Now, I think you can test import requests and this will work fine.

Further, if any error occurs then please let me know in the comments.

Thanks, HaPpY Coding 🤗

like image 43
Mayur Gupta Avatar answered Oct 22 '22 11:10

Mayur Gupta