I have a project structured like this:
.
└── myapp
├── app.py
├── models
│ ├── hello.py
│ └── world.py
└── requirements.txt
I have two models, hello
and world
. Both models are used from app.py
where I import them like this:
from models.hello import Hello
from models.world import World
But world
also needs to use hello
. I tried this in world.py
:
from models.hello import Hello
The above technically works when I run the app, but VSCode's Python extension gives me the following error:
E0401:Unable to import 'models.hello'.
What is the proper way of importing a submodule from the same directory? How do I avoid this error in VSCode?