【问题标题】:RichIPythonWidget import side effect on pkgutil moduleRichIPythonWidget 对 pkgutil 模块的导入副作用
【发布时间】:2014-05-30 17:26:53
【问题描述】:

显然,导入 RichIPythonWidget 对模块 pkgutil 有影响。

测试环境:

IPython 版本:2.1.0 python版本:2.7 & 2.7.6

代码显示问题:

import os
import pkgutil

print 'Before 1 ... '
pkgutil.find_loader('os') # call 1
print 'After call 1 ... '

from IPython.qt.console.rich_ipython_widget import RichIPythonWidget

print 'Before call 2 ... '
pkgutil.find_loader('os') # call 2
print 'After call 2 ... '

输出:

Before call 1 ... 
After call 1 ... 
Before call 2 ... 
Traceback (most recent call last):
  File "issue.py", line 11, in <module>
    pkgutil.find_loader('os') # call 2
  File "/u/bl/Dev/work/inkqt/opt.SuSE-11.4/lib64/python2.7/pkgutil.py", line 467, in find_loader
    loader = importer.find_module(fullname)
TypeError: find_module() takes exactly 3 arguments (2 given)

据我了解,我的问题似乎与添加到 sys.meta_path 的对象有关 IPython 使用,但 pkgutil 模块使用了错误的接口。 但我很难确定谁是有罪的……

任何解决方法将不胜感激。

谢谢

-贝诺特

【问题讨论】:

    标签: python python-2.7 ipython


    【解决方案1】:

    这很可能是由于 IPython 在 IPython/external/qt_loaders.py 中安装的 Qt ImportDenier。 find_module 方法不尊重 finder.find_module(fullname, path=None) 的 PEP302 签名,其中路径是可选的。

    我在 IPython 上提交了一个问题:https://github.com/ipython/ipython/issues/5932

    【讨论】:

      猜你喜欢
      • 2021-03-03
      • 1970-01-01
      • 2021-10-25
      • 1970-01-01
      • 2015-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多