IntelliJ confuses Python libraries with project modules

I'm using the Python plugin with IntelliJ IDEA and I have a project with (roughly) the following structure:

main_project
-subproject_a
-some_name
-util
-subproject_b
-some_name
-utils

and subproject_a is using a library from inside of a virtual environment

some_name
-utils

So in each of the two Python projects, I have a submodule with the same name as the library being used. Also, two of them contain a module named `utils` and one contains `util`. 

The problem appears when importing. 90% of the imports are absolute imports but the IntelliJ behaviour is quite odd. Let's say I want to import something from the `utils` submodule from the `some_name` library, so I would do something like this:

from some_name.utils.import_me import import_this
  • If I go to declaration from some_name, it directs me to subproject_a.some_name.__init__.py (which does not contain a utils module).
  • If I go to declaration from utils, it directs me to the library some_name.utils.__init__.py (which is what I would expect).
  • The rest of the import is just Cannot find reference/Unresolved reference. Also, I can't run the project because of this or debug it from IntelliJ.

I'm not sure if it's something from the project structure, if I need to mark some things as sources or something else or if I have to unmark something as a source. I need to work on both projects at the same time and be able to debug them. 

Please let me know if you have any tips, advice, etc. 

Thank you!

0

Please sign in to leave a comment.