Python 2.7.9:无法从模块导入

Python 2.7.9:无法从模块导入,python,importerror,Python,Importerror,我的目录结构如下所示: Project |+-- test.py | +>> agents | +-- __init__.py | +-- TestAgent.py | +>> automation | +-- __init__.py | | | +>> navigators | +--__init__.py | +--SystemNavigator.py 在代理下的u u__; init _u u; py.py内部,

我的目录结构如下所示:

Project
|+-- test.py
|
+>> agents
|  +-- __init__.py
|  +-- TestAgent.py
|    
+>> automation
|  +-- __init__.py
|  |
|  +>> navigators
|      +--__init__.py
|      +--SystemNavigator.py 
在代理下的u u__; init _u u; py.py内部,我有以下代码:

from TestAgent import TestAgent
在SystemNavigator中,我有:

from agents import TestAgent
当我尝试运行程序时,我得到:

Traceback (most recent call last):
File "test.py", line 1, in <module>
from navigators import SystemNavigator
File "/Users/jb/Desktop/code/tools/pythontest/automation/navigators/__init__.py", line 1, in <module>
from SystemNavigator import SystemNavigator
File "/Users/jb/Desktop/code/tools/pythontest/automation/navigators/SystemNavigator.py", line 1, in <module>
from agents import TestAgent
ImportError: No module named agents
回溯(最近一次呼叫最后一次):
文件“test.py”,第1行,在
从导航器导入SystemNavigator
文件“/Users/jb/Desktop/code/tools/pythontest/automation/navigators/_uinit__;.py”,第1行,在
从SystemNavigator导入SystemNavigator
文件“/Users/jb/Desktop/code/tools/pythontest/automation/navigators/SystemNavigator.py”,第1行,在
从代理进口测试代理
ImportError:没有名为代理的模块
我在一个单独的目录中设置了一个相同的文件结构以进行双重检查,并且我能够在那里工作。我阅读了有关堆栈溢出和其他地方的文章。我希望避免对sys.path或目录结构进行任何更改。根据其他人的建议,我尝试删除目录中的.pyc文件,并在代理下删除/重新创建y.py


有没有人建议我应该在哪里查找故障排除?我真的很感激

您的
系统路径上是否有
项目
目录?否则,您将无法从其中的包导入。我建议使用小写文件名。从TestAgent导入init.py TestAgent意味着TestAgent的名称有点含糊不清。请参阅,感谢您对此的反馈。将目录添加到sys.path以及如何从上面的目录导入python类的说明都是不错的选择。我很感激!您的
系统路径上是否有
项目
目录?否则,您将无法从其中的包导入。我建议使用小写文件名。从TestAgent导入init.py TestAgent意味着TestAgent的名称有点含糊不清。请参阅,感谢您对此的反馈。将目录添加到sys.path以及如何从上面的目录导入python类的说明都是不错的选择。我很感激!