【发布时间】:2019-05-26 03:58:44
【问题描述】:
我的目录结构如下:
toplevel/
subdir/
__init__.py
foo/
__init__.py
foo.py
bar/
__init__.pt
bar.py
如果我尝试在 bar.py 中使用 from foo import foo,并从 subdir 和 python3 bar/bar.py 执行 bar.py,它说找不到 foo。我使用了os.getcwd(),它是toplevel/subdir,所以它应该可以工作。我尝试过相对导入,但没有任何效果。
【问题讨论】:
-
有没有想过为什么使用
__init__.py文件/
标签: python python-3.x path python-import importerror