Search code examples
pythonpycharm

ModuleNotFoundError: No module named 'requests' but it's installed?


I used the command pip install requests in CMD and successfully installed the requests module, but when I try and import it to my file in PyCharm it throws

"ModuleNotFoundError: No module named 'requests'

I saw a couple other posts about this issue but did not find a working solution.

As a side note I have successfully run this code in my Python IDLE so I presume this is not a code issue, and just an issue with my PyCharm settings.

Traceback (most recent call last):
  File "C:/Users/danie/PycharmProjects/Web_Scraping_Project/Web_Scraper.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Process finished with exit code 1

Solution

  • You have to activate the virtual environment.

    source venv/bin/activate
    pip install requests
    

    Or you can add the library, from the PyCharm GUI. There is a "+" on the edit interpreter in settings in the, click on it and search for the requests library.