I am having the following directory structure.
A--Ab
|
|--Abc--main.py
|
|--Abd--*.py
|
Ac--*.py
I have placed __init__.py
files in every directory. and I am importing the files as below when I am in directory Abc
.This works fine when I am running the main.py file from inside the Abc
directory.
sys.path.insert(0, os.path.abspath("../../.."))
But when I am trying to run the main.py
file from Ab
directory as python Abc/main.py
, the import is not working.
I want to understand how can I fix this so that the imports can work , even if I am running the code from directory A or any other directory.
Updating dir structure
A--Ab
|-config.py
|-main.py
|-*.py