Python:无法从兄弟目录导入模块

时间:2015-06-19 10:10:53

标签: python import python-3.4 python-import

我正在使用Python 3.4

我克隆了一个git repo,其结构如下:

Parent_dir/
      .
      .#random things
      . 
      Sub_dir/

              Sub_dir1/
                    __init__.py
                    file1.py

              Sub_dir2
                    __init__.py
                    file2.py

              Sub_dir3
                    file3.py

              __init__.py

file2.py的内容

from Sub_dir.Sub_dir1.file1 import attibute1 #OK
from Sub_dir.Sub_dir3.file3 import attribute1 #gives an error that there is no module named Sub_dir3

我尝试将__init__.py文件添加到Sub_dir3但仍然给出了同样的错误。然后我试着尝试这个,所以我创建了自己的类似结构的项目,但在这种情况下一切正常。

在我正在使用的原始包装中是否有明显可以忽略的东西?

我的IDE是PyCharm。

我查看了这些12个问题,但找不到答案。

0 个答案:

没有答案