1
我正在编写的程序是写在Gtk + 3和Python。我问到有关我的程序的一个相关问题是here。现在与Python和Gtk + 3导入错误
,我提前多一点,我有以下的进口:
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)
进口模块为:APLpy和python-montage。
请帮我解决这些错误。任何帮助表示赞赏!
Germán。
感谢您的回答@Havok。现在我确信负责人是APLpy,因为评论其他人不会出错。但是我没有看到在APLpy中导入的任何pygtk。命令'grep -i pygtk /usr/lib/python2.7/site-packages/aplpy/*。py'的输出不会返回任何内容。 – skytux 2013-03-22 12:47:01
skytux是对的,在aplpy中没有gtk的明确使用,但aplpy使用matplotlib,它可以使用gtk。 @Havok,任何想法,如果matplotlib可以导致冲突? – keflavich 2013-04-12 00:18:59
这个问题已经解决,改变了** matplotlib后端**,因为[这里](https://github.com/aplpy/aplpy/issues/103) – skytux 2013-04-12 01:08:52