2

when i run server i have below error:

ModuleNotFoundError: No module named 'requests'

but requests have been installed on my system, when i run sudo pip3 install requests command, output is :

Requirement already satisfied: requests in /home/sadegh-khan/.local/lib/python3.6/site-packages

the terminal pic of my error and command to install requests is: ModuleNotFoundEr

Sadegh-khan
  • 2,535
  • 1
  • 20
  • 30
  • which command you are running to run server? – Gahan Apr 14 '18 at 15:45
  • python manage.py runserver 8002 – Sadegh-khan Apr 14 '18 at 15:45
  • 1
    try running `python3 manage.py runserver 8002` – Gahan Apr 14 '18 at 15:46
  • According to the following post: [Python module not found even though “Requirement Already satisfied in Pip” ](https://stackoverflow.com/a/45345642/5433307) easy-install solved my problem! `easy_install requests` but why!? – Sadegh-khan Apr 14 '18 at 16:00
  • python3 manage.py runserver 8002 would solved your problem because python manage.py runserver will run in python2 but you installed requests for python3 that is the problem – Syed Ali Apr 14 '18 at 16:03
  • after easy-install i tried python3 manage.py, but problem solved. Of course now also i am using python manage.py and i have not any problem. – Sadegh-khan Apr 14 '18 at 16:15

2 Answers2

0

You're installing requests by running pip as sudo, which means it is installed globally. Yet your screenshot (and please don't post screenshots anyway) shows you are inside a virtualenv, .venv.

Don't use sudo; just install requests inside the venv.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
0

If you are using Python3 instead of running the server using python manage.py runserver go ahead and run python3 manage.py runserver

Instead of

python manage.py runserver

or

py  manage.py runserver

Run python3 manage.py runserver

crispengari
  • 7,901
  • 7
  • 45
  • 53