Absolute import in nested project

Hi,

I have a problem with PyCharm recognizing the "global" modules from the nested project.

This is project structure

- main [PyCharm project] (Python path set in interpreter)
| - frm
| | - __init__.py
| | - generic.py (there is a class "generic")
| | - ...
| - subprj (Python path set in interpreter)
| | - sk [PyCharm project]
| | | - frm
| | | | - __init__.py
| | | | - sk_frm.py
| | | - __init__.py
| | | - ... *other .py files there *

"main" is the solo PyCharm project (with ignored subprj/*).

"sk" is solo PyCharm project (something like extension, has solo git repository; There are more projects like this there)

Python interpreter paths are set as described above.

Now, I have opened "sk" project in PyCharm. In "sk_frm.py" there is this code:

import frm.generic

class sk_frm(frm.generic.generic):
...

The code runs ok in our application (embedded python, but with same "interpreted" paths set as above) but the PyCharm does show warning "Cannot find reference 'generic' in 'imported module frm'". The problem is, that PyCharm thinks that "frm" package is the local one but it should be the global ("main") one.

I think the problem is that because PyCharm will set the "sk" as python "root" path and therefor absolute imports would try to load from the "sk" module and not from the "main" module. Could this be somehow fixed?

Thanks

Please sign in to leave a comment.