I am trying to import python files which have been developed. Initially, when all files were in the same directory then I there was no problems with them. However, I decided to split projects to dedicated directories. After that, I am unable to import files anymore.
My file structure is similar to the following:
dirFoo\
mainFoo1.py
dirFoo\
mainFoo2.py
dirFooCommon\
commonFoo.py
commonFoo2.py
Initially, I was trying to change the import path of my mainFoo1.py and do:
from dirFooCommon import commonFoo
. However, that approach gave me the following error:
ModuleNotFoundError: No module named 'common'.
Apart from that, I tried to use imp.load_source
which seems that is working. Unfortunately, this is generating so additional problems. For example what if some of the commonFoo.py libraries must include others? In this case, each of them needs to use an absolute project path, which will be a problem when I will try to use common libraries in any other place.
Do you have an idea what should I do to include my common libraries to my main projects?