I'm trying to use Importlib's Import_module to import some files, but I keep getting a module does not exist error. My directory structure looks a little like this:
a
/ \
c b
|
d
Where the letters all represent folders. My function is supposed to start in c, and then use os.path.walk to navigate down to d where it finds several py files and imports them. The problem is that import_module
is not finding the modules. I've tried simpler cases, for instance navigating to directory a and then trying to import test files from b and c. For some reason, when I do import_module('a.c.test_file1')
, it imports correctly, but when I try import_module('a.b.test_file2')
, it cant find the module. What am I missing?
Note: I've also tried relative paths to no avail
Nevermind, it has something to do with __init__py. One folder had them and the other folder didn't, which I assume is why I could import from one but not the other.