sparc_spread
sparc_spread

Reputation: 10843

Indexing of external library fails in PyCharm 4.5

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:

Having done this, the result is:

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?

Upvotes: 3

Views: 755

Answers (2)

sparc_spread
sparc_spread

Reputation: 10843

Checked w/ JetBrains support, they confirmed that the only ways to add external libraries to a PyCharm project are:

  • Add the library as a Content Root
  • OR
  • Open it as separate project in the same window and attach it to your current project

Not the cleanest approaches, as they both basically mean adding the other library's actual code to your project. But they are the only ones at this point.

Upvotes: 1

user1769868
user1769868

Reputation: 133

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.

Upvotes: 1

Related Questions