使用Python和Gtk导入错误+;3.

使用Python和Gtk导入错误+;3.,python,gtk3,pygobject,Python,Gtk3,Pygobject,我在一个用Gtk+3和Python编写的程序中工作。关于我的课程,我问了一个相关的问题是 现在,我又提高了一点,我有以下几个要点: import aplpy import montage import subprocess from gi.repository import Gtk, GdkPixbuf 当我运行它时,我会得到以下错误: $ ./makeRGB-frame.py Traceback (most recent call last): File "./makeRGB-fram

我在一个用Gtk+3Python编写的程序中工作。关于我的课程,我问了一个相关的问题是

现在,我又提高了一点,我有以下几个要点:

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".',))
我还得到一个错误:

$ ./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)
导入的模块为:和

请帮助我解决这些错误。感谢您的帮助


German.

您的一些模块正在使用静态Gtk+2.0绑定“PyGtk”: 您正在使用动态Gtk+3.0绑定“PyGObject”:

不能同时加载这两个库,如果同时加载,将出现导入错误和分段错误


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

谢谢你的回答@Havok。现在我确信负责人是冷静的,因为评论其他人不会出错。但我没有看到任何pygtk在APLpy中导入。命令
grep-ipygtk/usr/lib/python2.7/site packages/aplpy/*.py的输出不返回任何内容。skytux是正确的,在aplpy中没有明确使用gtk,但是aplpy使用matplotlib,它可以使用gtk@Havok,你知道matplotlib是否会导致冲突吗?这个问题在改变matplotlib后端后得到了解决,如前所述
$ ./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)