from pathlib import Path import sys ROOT = Path(__file__).resolve().parents[1] # project root directory two levels above this file if str(ROOT) not in sys.path: # making sure the project root is already in Python's module search path sys.path.insert(0, str(ROOT)) # adding the project root so local modules can be imported