PyCharm doesn't recognize installed module

anaconda, pip, pycharm, python, virtualenv

Solution

In my case, using a pre-existing virtualenv did not work in the editor - all modules were marked as unresolved reference (running naturally works, as this is outside of the editor's config, just running an external process (not so easy for debugging)). Turns out PyCharm did not add the site-packages directory... the fix is to manually add it.

On Pycharm professional 2022.3

Open File -> Settings -> Python Interpreter, open the drop-down and pick "Show All..." (to edit the config) (1), right click your interpreter (2), click "Show Interpreter Paths" (3).

In that screen, manually add the "site-packages" directory of the virtual environment [looks like `.../venv/lib/python3.8/site-packages` (4) (I've added the "Lib" also, for a good measure); once done and saved, they will turn up in the interpreter paths.

The other thing that won't hurt to do is select "Associate this virtual environment with the current project", in the interpreter's edit box.

Problem

I'm having trouble with using 'requests' module on my Mac. I use python34 and I installed 'requests' module via pip. I can verify this via running installation again and it'll show me that module is already installed. ``` 15:49:29|mymac [~]:pip install requests Requirement already satisfied (use --upgrade to upgrade): requests in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages ``` Although I can import 'requests' module via interactive Python interpreter, trying to execute 'import requests' in PyCharm yields error 'No module named requests'. I checked my PyCharm Python interpreter settings and (I believe) it's set to same python34 as used in my environment. However, I can't see 'requests' module listed in PyCharm either. It's obvious that I'm missing something here. Can you guys advise where should I look or what should I fix in order to get this module working? I was living under impression that when I install module via pip in my environment, PyCharm will detect these changes. However, it seems something is broken on my side ...

Original source

Related problems