gpt4 book ai didi

python - 在 KDE 上为 Python 导入 Gtk 类型库

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:50 24 4
gpt4 key购买 nike

我使用 Gtk 在 python 中编写了一个 GUI 应用程序。不幸的是,我不得不转移到一个新的操作系统,并且绝对必须使用它的 KDE 桌面。

现在 python 无法从 gi.repository 导入任何子模块,尽管安装了 python-gi 并且是最新的:

from gi.repository import Gtk, GObject, GLib

这似乎是 Linux 上的一个普遍问题,任何子模块引用gi.repository 无法解析,但奇怪的是 python GUI 是在我测试过的所有 Gnome 系统(Ubuntu、Lubuntu、Linux Mint)上仍然可执行并完美运行。

在 KDE 上不是这样。运行代码会产生以下错误:

ERROR:root:Could not find any typelib for Gtk
Traceback (most recent call last):
File "folder/Program.py", line 2, in <module>
from gi.repository import Gtk, GObject, GLib
ImportError: cannot import name Gtk

我有点迷茫如何克服这个错误。我想我必须安装一些 Gtk 系统包/类型库,但是哪个?

无法在网络上找到任何内容。

热烈欢迎任何建议!

信息:我正在使用 KDE 在 Debian Wheezy 上运行。

最佳答案

答案因发行版而异;例如,在基于 Debian/Ubuntu 的系统上,您必须安装 gir1.2-gtk-[23].0,具体取决于您要定位的 GTK+ 版本以及适当的 该版本的 libgtk*-dev。 (至少我认为;我不确定它们是否都需要为 Python 安装...)。

关于python - 在 KDE 上为 Python 导入 Gtk 类型库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27071495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com