This issue has come up with previous versions of PyCharm (see this SO post and this one), but it manifests somewhat differently in 4.5.
I am trying to add another library to the Python path of my current project. This is an internal library and consists of a bunch of .py
files in a different directory from the current project. I carry out the following steps:
- Go to
File -> Settings -> Project: summary -> Project Interpreter
- Click on the gear icon near the top right corner of the screen that appears in the dialog
- Select
More...
from the context menu that pops up - Click on the interpreter I am using
- Click on the last of the 4 icons to the right of that, the thing with a folder and arrows, with tooltip "Show paths for the selected interpreter"
- Push
+
in the resulting popup - Use the file dialog to add the path of the library
Having done this, the result is:
- Good:
- Running the current project code from a Run Configuration works; that is, the external library is picked up in the
PYTHONPATH
- The added path does not immediately disappear from the interpreter path dialog, as it was doing in 4.0 (see comment to this answer in one of the SO posts mentioned above).
- Running the current project code from a Run Configuration works; that is, the external library is picked up in the
- Bad:
- Indexing of the new library fails, and all references to the external library are marked as unresolved references in the editor
I have even tried File -> Invalidate Caches / Restart...
and pressed the Invalidate and Restart
button that appears. After sitting and waiting for indexing to finish, I get the same result. I have been very careful with setting the right path, and it seems to be correct, given that running the code actually works.
Does anyone know of a workaround for this issue, short of adding the external code as a content root?