Reputation: 317
My code fails when it tries to import requests, despite it already being installed. I did a pip list and saw the module requested there, I uninstalled it and reinstalled it with both pip install and pip3 install, also added sudo both times. Whenever I try to install it I get the message that the requirement is already satisfied. Is there something else that I could try? If it helps I am using VSCode on a Mac, I also have Jupyter and Spyder installed and have used them before however I’ve never used the requests module on this device.
UPDATE:
I created a virtualenv and installed requests there, when running the script in the venv I am not getting the error anymore, however I am still curious why it was being thrown on the base env, anything else I could check?
Upvotes: 0
Views: 2311
Reputation: 97
What worked for me was deleting three folders having names starting with "request-SOMETHING" in the directory that pip3 specifies when you try to install requests again, e.g.
Requirement already satisfied: requests in /usr/lib/python3/dist-packages
Then just reinstall with pip and it should be in your sys.executable directory.
Upvotes: 1
Reputation: 248
Try this
pip install chardet2 urllib3
or
python3 -m pip install requests
There is a problem with package dependency
Upvotes: 0
Reputation: 1375
You probably have multiple installations/environments.
Before the "import requests", line put "import sys; print(sys.executable)". This prints the python executable being used - verify that it is the same one that you can successfully import requests with .
Upvotes: 1