PyCharm doesn’t recognize installed module

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 steps

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.

Leave a Comment