PyCharm, resolve a library from a project folder

I have an ordinary library, presented in pypi. Inside it, there is a tricky way to resolve names in the modules that we import. If I install it to Python folder, in a common way, PyCharm resolves it, builds a skeleton and I get the auto-completion for it. But in our project, we are holding used libraries in a project folder and PyCHarm doesn't read and process the library. For this, I got the "unresolved references" inspection raising, and the red wave-line.

How can I make PyCharm resolve a library in a project folder?


Hi, you can try the following:

1. Ensure the directory with libraries is added in the project structure settings and marked as "sources".

2. Ensure it's added to the interpreter paths list, which can be found in the interpreter settings:




Andrey, thank you, but this didn't help still.

To be more precisely, let's look at example:


    -- external_libs



from external_libs.six.moves import range

But PyCharm wrote me, in the status bar:

Cannot find reference 'moves' in ''

I marked root of "MyProject" as sources root and "external_libs", too. (I guess, "external_libs" is redundant.)

Also, I added "MyProject" folder in the interpreter paths. 


Can you reproduce the issue in a minimal project, and provide the zipped project directory which can be reproduced on our side?


I added the external_libs folder to the path and used

from six.moves import range

After that, I invalidate the cache and restarted the IDE and it started working.

However, once I start editing the file (or even reformatting it with ctrl + alt + L) the error appears again.


@Dmarinov. Sorry, I have to use "external_libs" prefix because on real machines we won't configure python paths.


Thank you for the project, I think we got to the root of the issue.

When you install 'six' package using pip, it also installs stubs. When you just place libraries inside project root without stubs, it can't parse 'moves' because it's assembled dynamically. So the proper solution is, of course, to install the package properly.

However, PyCharm has it's own stubs for 'six' bundled, which you can copy to the project root. They are located in "<pycharm_install_path>\helpers\typeshed\third_party\3\six"

You can do the following:

1. Create directory <project_root>/external_stubs/external_libs

2. Copy "<pycharm_install_path>\helpers\typeshed\third_party\3\six" to that directory

3. Add "<project_root>/external_stubs" directory to project structure and mark it as sources. Alternatively you can add it to interpreter paths.

This way we gave PyCharm stubs to resolve module names, which should eliminate the warning.


However the behavior reported by @Dmarinov seems like a bug, so we've also created a ticket for it:


Anrtey, yep, thank you for the answer! It works!

I put the .pyi file near my six and PyCHarm proceced it. 


Please sign in to leave a comment.