I have the following folder structure:
<project_name>
|__ <docs>
|__ <configs>
|__ <src>
.....|__  __init__.py
.....|__  utils.py
.....|__ <feature1>
..........|__ __init__.py
..........|__ feature1.py
where names enclosed in triangle brackets are folders.
From within feature1.py, I want to import utils.py. Since src is the highest level folder with an __init__.py file, I would have thought that that would be the package, meaning that I would need to do:
from src import utils
This does not work, and gives the error:
Exception has occurred: ModuleNotFoundError
No module named 'src'
However, when I run
from project_name.src import utils
it works fine. As I understand it, project_name is not a package, since it has no __init__.py file. Why is this required, and is there a way to get it to recognise src as the package?
 
    