Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexing of external library fails in PyCharm 4.5

Tags:

python

pycharm

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).
  • 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?

like image 412
sparc_spread Avatar asked Dec 14 '25 02:12

sparc_spread


1 Answers

I ran into a very similar issue. I am working on an OpenStack component, and all third-party libraries were getting marked as unresolved references. It turned out to be because the .tox directory is automatically excluded by PyCharm, which prevents any virtual environments in that directory from getting indexed properly.

To fix this, I went to the Editor > File Types dialog of the Preferences menu, and removed the .tox folder from the Ignore files and folders option.

like image 167
user1769868 Avatar answered Dec 16 '25 16:12

user1769868



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!