我在我的站點包目錄中安裝了一個軟件包。文件夾結構看起來像這樣從__init__文件導入時出現python錯誤
MyPkg\
__init__.py
LogUtils\
__init__.py
logwrapper.py
Shortcuts\
__init__.py <-----this references LogUtils
somefile.py
當我做help ('modules')
我看到列出MyPkg
。但我在IDLE中出現以下錯誤:
>>> import MyPkg
>>> from MyPkg import LogUtils
>>> from MyPkg import Shortcuts
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from MyPkg import Shortcuts
File "C:\Python27\lib\site-packages\MyPkg\Shortcuts\__init__.py", line 1, in <module>
from GoToUrl import go_to_url
File "C:\Python27\lib\site-packages\MyPkg\Shortcuts\GoToUrl.py", line 1, in <module>
from LogUtils import logger, log
ImportError: No module named LogUtils
爲什麼LogUtils可以單獨導入,但是在通過init文件導入時會拋出錯誤?