Error: ImportError: No module named common_components.modules.logging.logger
passiert beim Ausführen python emailsender.py
.Python: ImportError meines eigenen Moduls
Ausgang:
(dev) [email protected]:~/workspace/python/python/common_components/modules/email$ python emailsender.py
Traceback (most recent call last):
File "emailsender.py", line 23, in <module>
from common_components.modules.logging.logger import Log
ImportError: No module named common_components.modules.logging.logger
Nicht sicher, ob etwas nicht in Ordnung mit der folgenden Projektstruktur:
(dev) [email protected]:~/workspace/python/python$ tree
.
├── common_components
│ ├── __init__.py
│ ├── modules
│ │ ├── email
│ │ │ ├── emailsender.py
│ │ │ └── __init__.py
│ │ ├── __init__.py
│ │ ├── logging
│ │ │ ├── __init__.py
│ │ │ └── logger.py
└── __init__.py
eine Idee? Dank
UPDATE
(dev) [email protected]:~/workspace/python$ python python/common_components/modules/email/emailsender.py
Traceback (most recent call last):
File "python/common_components/modules/email/emailsender.py", line 23, in <module>
from common_components.modules.logging.logger import Log
ImportError: No module named common_components.modules.logging.logger
(dev) [email protected]:~/workspace/python$ cd python/
(dev) [email protected]:~/workspace/python/python$ python common_components/modules/email/emailsender.py
Traceback (most recent call last):
File "common_components/modules/email/emailsender.py", line 23, in <module>
from common_components.modules.logging.logger import Log
ImportError: No module named common_components.modules.logging.logger
'common_components' ist nicht in Ihrem Python-Pfad. Der einfachste Weg, dies zu lösen, besteht darin, das Skript von '.' mit' python common_components/modules/email/emailsender.py' auszuführen. Das Arbeitsverzeichnis befindet sich immer im Python-Pfad. –
Ihr 'python'-Verzeichnis enthält '__init __. Py'. Ich bin mir nicht sicher, ob das einen Unterschied macht, aber es scheint komisch, da ich mir vorstelle, dass du nicht vorhast, dass es ein Paket ist. –