Python code navigation?

Completed

I am writing some python code to support a swagger-generated (python flask) server using IntelliJ 2018.3.2 on Ubuntu. When I try to Ctrl-click my modules or methods, IntelliJ will not navigate to them - I get a 'Cannot find declaration' error tooltip. However, I know the code is parsing correctly (syntax highlighting is fine, PEP formatting rules are applied, and auto-completion for built-in methods seems to work fine). So is there some reason that IntelliJ can't find my other modules (located in the same directory)?

0
6 comments

Hi,

Does it happen with just one particular module or all of them?

Please try File | Invalidate Caches / Restart... . Has it helped?

 

0
Avatar
Permanently deleted user

I tried that, and it still does not address the issue.

0

Would it be possible to provide a screenshot showing the problem and another one with your Project Structure (Settings | Project | Project Structure)?

0
Avatar
Permanently deleted user

The module it is having issues finding is in the same directory as the caller, and the code runs fine.

0

Thanks!

You should mark src directory as Sources (right click the directory in project view --> Mark Directory as --> Sources Root) when importing something that isn't located on the project level.

Another option is to set path to the module when importing, like:

import src.utils

1
Avatar
Permanently deleted user

Thank you, Sergey, that worked great! 

0

Please sign in to leave a comment.