I'm trying to import a function from a file which is in another module but keep getting the following error.
ValueError: Attempted relative import in non-package
I have seen lots of articles saying do absolute instead of relative imports but then get the error
ImportError: No module named app.main.events
My file structure
\_ dir
\_ __init__.py
\_ app
\_ main
\_ __init__.py
\_ events.py
\_ game
\_ __init__.py
\_ run.py
events.py
def my_function():
do something....
run.py
from ..main.events import my_function
# returns
Attempted relative import in non-package
from app.main.events import my_function
# returns
No module named app.main.events
I can't see where im going wrong... It's probably something so simple.