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. windows8.1+ubuntu 14.04双系统安装
  2. debain 系统 ll 命令无法使用.目录和文件没有颜色区分解决之道
  3. 报告节选3:Linux比例近半 操作系统混战虚拟化
  4. Linux系统中使用fdisk命令为U盘分区,并将其中一个分区设置为启动
  5. 嵌入式Linux系统工程师系列之ARM920T的MMU与Cache
  6. windows10 下访问 virtualbox 虚拟机的linux15.10/16.04 系统 及
  7. 基于GUI和SQL的剧院票务管理系统
  8. Linux系统下安装MySql 5.7.17 全过程
  9. 利用JAVA动态编译重构系统

随机推荐

  1. 系出名门Android(6) - 控件(View)之DateP
  2. android随笔
  3. android学习之RelativeLayout
  4. Android Power Manager分析(转载整理)
  5. android widget之TextView
  6. Android TextView跑马灯效果
  7. android中控件的大部分属性解释
  8. Android OpenGL ES 开发教程小结
  9. Android EditText属性
  10. Android SDK下载用的代理