I have written a GUI application in python making use of Gtk. Unfortunately I had to move to a new OS and absolutely have to use its KDE desktop.
我在python中编写了一个使用Gtk的GUI应用程序。不幸的是,我不得不迁移到一个新的操作系统,绝对必须使用它的KDE桌面。
Now python can not import any of the submodules from gi.repository, despite python-gi being installed and up to date:
现在python无法从gi.repository导入任何子模块,尽管安装了python-gi并且是最新的:
from gi.repository import Gtk, GObject, GLib
It seems to be a general problem on Linux, that any submodule references of gi.repository can not be resolved but strangely enough the python GUI was still executable and ran flawlessly on all Gnome systems (Ubuntu, Lubuntu, Linux Mint) I tested it on.
这似乎是Linux上的一个普遍问题,gi.repository的任何子模块引用都无法解析,但奇怪的是python GUI仍然是可执行的,并且在所有Gnome系统上运行完美(Ubuntu,Lubuntu,Linux Mint)我测试了它。
Not so on KDE. Running the code yields the following error:
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
I am a bit lost how to overcome this error. I think I have to install some Gtk system packages/typelib, but which?
我有点迷失如何克服这个错误。我想我必须安装一些Gtk系统软件包/ typelib,但是哪个?
Could not find anything on the web.
在网上找不到任何东西。
Any suggestions are warmly welcome!
热烈欢迎任何建议!
Info: I am running on Debian Wheezy with KDE.
信息:我正在使用KDE在Debian Wheezy上运行。
1 个解决方案
#1
1
The answer differs per distribution; for instance, on Debian/Ubuntu-based systems, you have to install gir1.2-gtk-[23].0
depending on which GTK+ version you want to target as well as the appropriate libgtk*-dev
for that version. (At least I think; I'm not sure if they both need to be installed for Python or not...).
每个分布的答案不同;例如,在基于Debian / Ubuntu的系统上,您必须安装gir1.2-gtk- [23] .0,具体取决于您要定位的GTK +版本以及该版本的相应libgtk * -dev。 (至少我认为;我不确定它们是否都需要为Python安装......)。
#1
1
The answer differs per distribution; for instance, on Debian/Ubuntu-based systems, you have to install gir1.2-gtk-[23].0
depending on which GTK+ version you want to target as well as the appropriate libgtk*-dev
for that version. (At least I think; I'm not sure if they both need to be installed for Python or not...).
每个分布的答案不同;例如,在基于Debian / Ubuntu的系统上,您必须安装gir1.2-gtk- [23] .0,具体取决于您要定位的GTK +版本以及该版本的相应libgtk * -dev。 (至少我认为;我不确定它们是否都需要为Python安装......)。