I have a directory structure as shown below:
--root
--common
util.py
--submodule
--common
util.py
--code
a.py
run.py
main.py
a.py
from common.util import test_config
main.py
import submodule.a
a.py is importing some code from common module of the submodule. I have added this submodule in root project. the submodule itself works fine when run independently.
When I import a.py in main.py it starts to pick up code from root projects common code instead of the submodule project.
ImportError: cannot import name 'test_config'
I have tried adding sys.path in a.py to force import submodule code but it is not working.
a.py
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from common.util import test_config
Any help is appreciated