Python 2.7 __导入与导入加载模块
尝试使用ironpython安装autopep8时出错:Python 2.7 __导入与导入加载模块,python-2.7,import,ironpython,Python 2.7,Import,Ironpython,尝试使用ironpython安装autopep8时出错: ImportError: No module named logilab 它失败的代码段是: def load_module(self, fullname): self._reopen() try: mod = imp.load_module(fullname, self.file, self.filename, self.etc) finally: if self.file:
ImportError: No module named logilab
它失败的代码段是:
def load_module(self, fullname):
self._reopen()
try:
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
finally:
if self.file:
self.file.close()
# Note: we don't set __loader__ because we want the module to look
# normal; i.e. this is just a wrapper for standard import machinery
return mod
使用解释器ipy64导入logilab没有失败。
我为文件名添加了打印语句,它显示:
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\logilab_common-0.59.1-py2.7.egg\logilab
路径存在,并且它包含一个包含以下内容的init.py:
"""generated file, don't modify or your data will be lost"""
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
pass
我通过添加
except ImportError:
mod = __import__(fullname)
但是我对这个修复方案感觉不太好,因为我不知道可能的影响
现在,为什么使用imp.load_模块会失败?使用导入有什么区别