How to import local modules with Python - Quentin Fortier

1st solution: add root to sys.path

We can add the path to the root of the project:

from pathlib import Path
import sys
path_root = Path(file).parents[2]
sys.path.append(str(path_root))
print(sys.path)

import src.c.d
view raw

Link to the original article

The Analog Pixel