Python没有名为error的模块

时间:2017-04-08 13:24:36

标签: python

tree
 systemMonitoring
├── ddos_logging_service.py
├── __init__.py
├── setup.py
├── systemMonitor
│   ├── __init__.py
│   ├── monitor.py
│   └── source.py
└── systemMonitor.service

它是我的python程序文件层次结构...... 我在我的python程序上创建了systemMonitor目录,以便从其他人分离setup.py和服务文件。分离后,当我尝试运行monitor.py时,我收到此错误:

    File "monitor.py", line 3, in <module>
    from systemMonitor import source  
    ImportError: No module named 'systemMonitor'

开始monitor.py是:

  #!/usr/bin/python3
import time,psutil
from systemMonitor import source

1 个答案:

答案 0 :(得分:1)

systemMonitor/monitor.py

#!/usr/bin/python3
import time,psutil
from . import source

请检查:https://docs.python.org/2.5/whatsnew/pep-328.html