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`

Try to uninstall requests and then again install it using pip

pip uninstall requests

and again install it

pip install requests

or if you didn't get what I am saying so please visit

https://scmquest.com/resolved-importerror-no-module-named-requests-usr-bin-python-no-module-named-pip-on-macos/


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.


If it is installed this will WORK:

c:\>python  (or on Mac/Linux "$ python")
>>> import requests
>>> requests.get("http://127.0.0.1")
<Response [200]>

If you see this error when running your script/IDE:

Traceback (most recent call last): File "E:\test.py", line 1, in <module>

import requests
ImportError: No module named requests

Try:

python script.py

Answer is based on https://www.edureka.co/community/84584/python-requests-module-import-error-module-named-requests

Then the trick for me was not to start up a VirtualEnv, I actually found I was running the x64 version of python when I'd installed the requests package into the python 32 bit folder c:\program files (x86)\python37-32\lib\site-packages. This is a screenshot from the internet but it shows you how to change the interpreter you're using - in my case - I need to set it to Python 3.7.4(x86) 32 bit:

enter image description here


Another cause of this might be multiple Python versions installations. So if you type in your terminal:

pip3 install requests 

The requests library will be automatically installed to your default python3, for example, Python3.6. However, let's say you have another Python version, for example, Python3.7, what you should do is:

pip3.7 install requests

This should solve this problem.

If you are running your code in the terminal, you should try:

python3.7 file_to_run.py