PyCharm not indexing site-packages in virtualenv

Answered

If I set my project's interpreter to any system Python install (in /usr/bin), I can browse site-packages in External Libraries just fine; packages are detected, imports resolve, everything is how it should be.

However, if I create a virtualenv and set it as the project interpreter, PyCharm fails to detect the <venv>/lib/python3.5/site-packages directory, so imports for installed packages create warnings in the editor and autocompletion doesn't work. Bizarrely, the program works fine when run from PyCharm, and the packages even show up in Settings/Project/Project Interpreter, they just aren't being used by the editor.

I've checked the interpreter paths, and they definitely include <venv>/lib/python3.5/site-packages. I've tried different Python versions, I've tried installing packages with pip manually, I've done the invalidate caches & restart dance -- why's PyCharm complaining that imports don't resolve whilst simultaneously acknowledging that I have the right packages installed?

1
7 comments

Please, file an issue to PyCharm bug-tracker: https://youtrack.jetbrains.com/issues/PY with screenshots of the issue and your idea.log (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) to let us investigate it. Thank you!

0
Avatar
Permanently deleted user

I'm seeing exactly the same behavior with IntelliJ IDEA 2018.1. I'd copy and paste the build number, but sadly it's not copy/pastable from the dialog

0

steps to reproduce: 1) open python project (idea .) 2) create and activate venv in terminal, pip install -r req.txt 3) set intellij python interpreter to new venv

up to this point, very reasonable experience with everything. then it all falls apart when you:

4) pip install . -e

and intellij just cannot catch up to this - even though “run context” even though you can launch scripts and they import the modules, but intellij cannot reindex.

0

Daveankin Interesting. Does it help to rebuild caches after doing pip install . -e ? 

You can do it using File | Invalidate Caches... | Clear file system cache and Local History | Invalidate and Restart

0

Andrey, I created a reproducer in idea-337185 

0

Daveankin Thank you for the clear repro steps 👍

0

Responding in ticket - clearing caches does not help.

0

Please sign in to leave a comment.