简体   繁体   English

python3 Gtk程序抛出introspection typelib错误

[英]python3 Gtk program throws introspection typelib error

I am trying to convert a python2 GtK program, specifically Comix , to python3 Gtk program.我正在尝试将 python2 GtK 程序(特别是Comix )转换为 python3 Gtk 程序。

I have reached a point where the program throws an error:我已经到了程序抛出错误的地步:

ImportError: cannot import name Gobject, introspection typelib not found导入错误:无法导入名称 Gobject,未找到自省类型库

The error is thrown at this point:此时抛出错误:

from gi.repository import Gobject

at bookmark.py .bookmark.py Anyway the program itself contains various linked py files and it's not that simple to present the structure.无论如何,程序本身包含各种链接的 py 文件,呈现结构并不是那么简单。

The funny thing is that the same import command is executed in other modules in the same program with no problem.有趣的是,在同一个程序中的其他模块中执行相同的导入命令没有问题。 I am not sure what's the problem here.我不确定这里有什么问题。

Some solutions mentioned as to install gir1.2-gtk-3.0 is satisfied but to no avail.提到安装gir1.2-gtk-3.0一些解决方案是满意的,但无济于事。 Also I installed my modules using pip and to compile them using --enable-introspection=yes seems an overkill to me.此外,我使用 pip 安装了我的模块并使用--enable-introspection=yes编译它们对我来说似乎有点矫枉过正。 There should be another solution.应该有另一个解决方案。

Any idea what's going on here and how to deal with it?知道这里发生了什么以及如何处理吗?

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

from gi.repository import GObject

if you use Linux like : Ubuntu, Fedora,...如果您使用 Linux,例如:Ubuntu、Fedora、...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM