Tag: python-import

How to do relative imports in Python?

The Question : 539 people think this question is useful Imagine this directory structure: I’m coding mod1, and I need to import something from mod2. How should I do it? I tried from ..sub2 import mod2 but I’m getting an “Attempted relative import in non-package”. I googled around but found only “sys.path manipulation” hacks. Isn’t