Unresolved reference when importing from sibling sub-package with

I have following similar directory structure.

main.py
pack
   |___sub_pack1
|__a.py
   |___sub_pack2
|__b.py

Now inside main.py (which is my main program that I execute) I am importing like follow
from pack.sub_pack1 import a

Working fine.

Inside a.py I am importing like follow
from pack.sub_pack2 import b

At this point pycharm underlines above code as red and notifying me "Unresolved reference pack".

Now my code is working fine which should. I am curious why pycharm considering it as error and what can I do to avoid such thing.

Thanks
ansumanbebarta
1 comment
Hi ansumanbebarta,

Please make sure that sub_pack2 is included in project structure (please refer to http://www.jetbrains.com/pycharm/webhelp/configuring-folders-within-a-content-root.html) and you have __init__.py in pack and sub_pack2 folders. Whether it does not help please attach a sample project that does not work.
0

Please sign in to leave a comment.