3

我正在编写一个用Gtk+ 3Python编写的程序。我问我的程序的一个相关问题是here

现在,我进步了一点,我有以下导入:

import aplpy
import montage
import subprocess
from gi.repository import Gtk, GdkPixbuf

当我运行它时,我得到了这个错误:

$ ./makeRGB-frame.py 
Traceback (most recent call last):
  File "./makeRGB-frame.py", line 34, in <module>
    from gi.repository import Gtk, GdkPixbuf
  File "/usr/lib64/python2.7/site-packages/gi/__init__.py", line 27, in <module>
    from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

如果我更改导入的顺序:

from gi.repository import Gtk, GdkPixbuf
import aplpy
import montage
import subprocess

我也收到一个错误:

$ ./makeRGB-frame.py 
/usr/lib64/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
  from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

导入的模块是:APLpypython-montage

请帮助我解决这些错误。任何帮助表示赞赏!

德语。

4

1 回答 1

3

您的一些模块正在使用静态 Gtk+ 2.0 绑定“PyGtk”:http ://www.pygtk.org/ 您正在使用动态 Gtk+ 3.0 绑定“PyGObject”:https ://live.gnome.org/PyGObject

您不能同时加载这两个库,如果这样做,您将遇到导入错误和分段错误。

我的客人是负责 APLpy 模块,您应该检查源代码以查找 PyGtk 导入,或者询问开发人员是否支持 PyGObject。

于 2013-03-22T11:34:49.210 回答