I have a directory structure as follows:
test/
__init__.py
m1/
__init__.py
f1.py
f2.py
test/__init__.py is empty.
test/m1/__init__.py contains a single line import test.m1.f1.
test/m1/f1.py contains a single line import test.m1.f2 as f2.
In python 3.7.6, I can do import test.m1 and everything works as expected. However, in python 3.6.9 when I try this I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/scratch/test/m1/__init__.py", line 2, in <module>
import test.m1.f1
File "/home/scratch/test/m1/f1.py", line 1, in <module>
import test.m1.f2 as f2
AttributeError: module 'test' has no attribute 'm1'
This seems strange, because it does not error on the import test.m1.f1, which is the first thing it encounters. It errors on a subsequent import test.m1.f2 as f2 statement, claiming that test has no m1 submodule.