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
答案 0 :(得分:1)
在systemMonitor/monitor.py
:
#!/usr/bin/python3
import time,psutil
from . import source