How to import a module in a subdirectory that imports another module in that same subdirectory?

Viewed 572

In a module that I import, I'm trying to import another module, that is located in that same directory.

My files look something like this...

project
├── main.py
└── app
    └── foo.py
    └── bar.py

main.py

import app.foo as Foo

foo.py

import bar

So now, when I run main.py, I get a

ModuleNotFoundError: No module named 'bar'

There are so many similar questions, but none of them seem to be my exact situation.

How can I get this to work?

2 Answers
Related