If I have a file structure like this:
backend
├─api_layer
├─ app.py
├─database_layer
├─ service.py
In app.py, how do I import from service.py?
I've tried
import sys
# setting path
sys.path.append('../database_layer')
import database_layer.service as DBService
I've also tried to add an empty __init__.py
file to database_layer
directory.
None of them work.
When I run python3 app.py
, they all have ModuleNotFoundError: No module named 'database_layer'
error.
Is importing from parent's subdirectory even possible in python?