导入 Glib 时出错

Koo*_*rus 4 python glib importerror traceback python-3.x

尝试在 python 3 中使用 导入 glib 时from gi.repository import glib,我收到一条错误消息:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2135, in _find_spec
AttributeError: 'DynamicImporter' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 53, in find_module
    'introspection typelib not found' % namespace)
ImportError: cannot import name glib, introspection typelib not found
Run Code Online (Sandbox Code Playgroud)

我在 Ubuntu 14.04 上使用 apt-get 安装了所有 python glib/dev 包。尝试在 python 2 中导入模块表示该模块不存在。

我该如何解决?

Dan*_*etz 6

它适用于我GLib正确的大写:

from gi.repository import GLib
Run Code Online (Sandbox Code Playgroud)