In order to import modules with package path with dot separators, all sub-directories must come with the files.

Example directory structure:


Python standard import:

from modules.file1            import someclassname
from modules.submodule1.file2 import someclassname
from modules.submodule2.file3 import someclassname

Python relative path import from path of current file:

#use the same directory structure above
#example content for

import os
import sys

#paths for relative modules (from current file)
__realpath__ = os.path.realpath(__file__)
__dirname__  = os.path.dirname(__realpath__)
sys.path.append(__dirname__+"/..") #parent dir
sys.path.append(__dirname__+"/../submodule1") #sibling dir

from file1 import someclassname
from file2 import someclassname