I have this file structure in my python project
|__src
|__main.py
|__gen.py
|__app
|__ __init__.py
|__ app.py
|__ lang.py
I want to use the Language
class from sibling module lang
.
So I tried with this import statement in app.py
:
from app.lang import Language
But when I run app.py
I get a ModuleNotFoundError error saying 'app' is not a package
:
Which doesn't make sense since app has __init__.py
.
How can I solve this?
Because both app.py
and lang.py
are in the same directory try to import like this :
from .lang import Language
or you can use from app.lang import Language
from another file located outside app folder