from pkg1.module1 import func1 from other import other from pkg1.pkg11.module11 import func11 from pkg2.module2 import func2
defmain(): print('main')
other() func1() func11() func2()
现在我们在module1里引用module2的函数:
1 2 3 4 5
# module1.py
from pkg2.module2 import func2
func2()
就出现问题了:
1 2 3 4 5
$ python module1.py Traceback (most recent call last): File "module1.py", line 6, in <module> from pkg2.module2 import func2 ModuleNotFoundError: No module named 'pkg2'