python3 Gtk 程序抛出内省类型库错误

python3 Gtk program throws introspection typelib error

我正在尝试将 python2 GtK 程序,特别是 Comix 转换为 python3 Gtk 程序。

我已经到了程序抛出错误的地步:

ImportError: cannot import name Gobject, introspection typelib not found

此时报错:

from gi.repository import Gobject

bookmark.py。无论如何,程序本身包含各种链接的py文件,并且呈现结构并不是那么简单。

有趣的是,同一个import命令在同一个程序的其他模块中执行没有问题。我不确定这里有什么问题。

一些solutions提到安装gir1.2-gtk-3.0很满意但无济于事。我还使用 pip 安装了我的模块并使用 --enable-introspection=yes 编译它们对我来说似乎有点矫枉过正。应该还有别的解决办法。

知道这里发生了什么以及如何处理吗?

模块名称区分大小写,试试这个:

from gi.repository import GObject

如果您使用 Linux,例如:Ubuntu、Fedora、...

#!/usr/bin/python3 
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject