Reputation: 9823
I'm getting "Attempted relative import in non-package" in this import statement. Where is the issue?
from ..Resources.UniversalHelper.Helper import UniversalPageHelper
Structure:
project/
__init__.py
MainFiles/
__init__.py
Main.py (where this from statement is being called)
Resources/
__init__.py
UniversalHelper/
__init__.py
Helper.py
Upvotes: 1
Views: 796
Reputation: 39863
It doesn't really matter that you've put __init__.py
files in every directory. It seems to me, that importing Main.py
is done by import Main
somewhere or by running the scriptpython project/MainFiles/Main.py
.
ValueError: Attempted relative import in non-package
tells you, that Main
is not loaded as part of a package structure. You need to import it as complete package like import project.MainFiles.Main
or run it as module python -m project.MainFiles.Main
.
If the last is your problem, you should also have a look into __main__.py
.
Upvotes: 4