我在我的程序中输入了以下导入解析错误:
I am: homie.translators.is24.rest.translator
Traceback (most recent call last):
File "/usr/local/sbin/is24rest", line 3, in <module>
from homie.interfaces.is24.rest import __main__
File "/usr/local/lib/python3.2/dist-packages/homie/interfaces/is24/rest/__init__.py", line 8, in <module>
from .exporter import Exporter
File "/usr/local/lib/python3.2/dist-packages/homie/interfaces/is24/rest/exporter.py", line 12, in <module>
from homie.translators.is24.rest.translator import Translator
File "/usr/local/lib/python3.2/dist-packages/homie/translators/is24/rest/translator.py", line 9, in <module>
from .factories.rest.restFactory import RestFactory
ImportError: No module named factories.rest.restFactory
/usr/local/lib/python3.2/dist-packages/homie/translators/is24/rest/translator.py
的内容是
"""
Created on 18.06.2014
@author: Richard Neumann
"""
print('I am: ' + str(__name__))
from homie.translators.abc import Translator as T
from .factories.rest.restFactory import RestFactory
from .factories.openimmo.openimmoFactory import OpenImmoFactory
class Translator(T):
<snip>
此外,相关模块存在:
root@srv:/usr/src/is24-translator# ls /usr/local/lib/python3.2/dist-packages/homie/translators/is24/rest/factories/rest/
abc.py attachments __init__.py __pycache__ realestates restFactory.py
为什么python3尝试在这里进行绝对导入? 我只使用python 3.2.3在Debian 7下遇到这个问题。 在Arch w / python 3.4.1下,它运行得很好。
我错过了什么吗?
答案 0 :(得分:2)
.factories
中缺少__init__.py,导致此错误。
我花了一段时间才意识到这一点。