Search code examples
pythonpippython-importmodulenotfounderror

ModuleNotFoundError for requests


I'm extremely new to Python, so I can only apologize for my unadulterated incompetence.

I'm trying to learn to web scrape, so I did pip install requests and that worked fine.

In PyCharm, however, I receive ModuleNotFoundError: No module named 'requests' when I try import requests.

PyCharm offers from pip._vendor import requests to rectify this, but from this I get:

AttributeError: partially initialized module 'pip._vendor.requests' has no attribute 'Session' (most likely due to a circular import)

Any help would be greatly appreciated.


Solution

  • PyCharm may be using a different python (perhaps from a virtualenv) than the one you pip installed from.

    You should also be able to pip install requests from PyCharm's terminal, which should be using the same python as the code you ran.

    If you're not using a virtual environment, or similar, I'd highly recommend it. https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html# might be useful for you.