0

import request is not working

If I am trying to install requests it is showing requirement already satisfied but If I am trying to import then it is throwing error.

Traceback (most recent call last):
File "", line 1, in 
ModuleNotFoundError: No module named 'requests'.

I am running the command pip3 list then it is showing requests 2.23.0. but not able to import.

kichik
  • 33,220
  • 7
  • 94
  • 114
s.prakash
  • 3
  • 3
  • Can you please share complete error ? – Shakeel Apr 18 '20 at 23:42
  • `pythonyouareusing -m pip intall requests` then `python your_script.py` - your pip3 does not match the python you are running under. – modesitt Apr 19 '20 at 00:00
  • Does this answer your question? [Dealing with multiple Python versions and PIP?](https://stackoverflow.com/questions/2812520/dealing-with-multiple-python-versions-and-pip) – modesitt Apr 19 '20 at 00:01
  • Apples-MacBook-Pro:withoutrest apple$ python3 test.py Traceback (most recent call last): File "test.py", line 1, in import requests ModuleNotFoundError: No module named 'requests' Apples-MacBook-Pro:withoutrest apple$ python3 test.py Traceback (most recent call last): File "test.py", line 1, in import requests ModuleNotFoundError: No module named 'requests' But if I run pip3 list then it is showing requests version Apples-MacBook-Pro: without rest apple$ pip3 list Package Version requests 2.23.0 @Shakeel – s.prakash Apr 19 '20 at 00:05
  • Does it now show you on which python path it failed to load ? as suggested by #modesitt you need to install packages under python which you are using. Best practice is to create virtualenv and install your dependency over there. – Shakeel Apr 19 '20 at 00:12
  • Yea sure lets connect over hangout, I have sent you the invite on `sumit.sumitprakash@gmail.com` – Shakeel Apr 19 '20 at 00:36

1 Answers1

0

From the shared error link I could notice that you have two python version installed in you system and you have installed requests on python3.7 (i.e, /usr/local/lib/python3.7/site-packages) and trying to import requests on python3.8

Solution: Either install requests on python3.8 (I guess it should be pip3.8 install requests) OR run your script from python3.7

Shakeel
  • 1,869
  • 15
  • 23