0

我收到一个错误

Couldn't find conversion for foreign struct 'cairo.Context' in <module 'threading' from '/usr/lib.python2.7/threading.pyx'> ignored

我在网上所做的所有研究都表明缺少一个包 python-gi-cairo 或 python-gobject。

我已经安装了所有这些依赖项,但仍然收到消息。我已经确定我安装了 python-gi-cairo、python3-gi-cairo、python-gobject、libcairo-gobject2 等。在我开始尝试使用 Gtk.DrawingArea 之前,其他绑定对我来说一直很好。

这是代码:

from gi.repository import Gtk, Gdk
class MyExample(object): 
  def __init__(self, user_data=None): 
    window = Gtk.Window() 
    window.connect("destroy", Gtk.main_quit) 
    drawing_area = Gtk.DrawingArea() 
    drawing_area.set_size_request(300,300) 
    drawing_area.connect('draw',self.expose) 
    window.add(drawing_area) 
    window.show_all()  
  def expose(self,widget,cr,data): 
    print ("self_exposed") 
# === 
if __name__ == "__main__": 
    app = MyExample() 
    Gtk.main() 

使用 python2 和 python3 运行它时,我得到了同样的错误。如果我打开 Python shell 并输入“import cairo”,则没有错误。我在互联网上找不到任何我尚未阅读的信息。有任何想法吗?

我正在运行 Ubuntu 13.10。我已经更新了 apt-get,删除并重新安装了 python-gi-cairo 等。

4

1 回答 1

0

我能够解决问题的唯一方法是重新格式化并重新安装 Ubuntu。不知何故,我的安装搞砸了,但是卸载/重新安装软件包的次数都没有取得任何进展。

于 2014-01-28T03:06:41.940 回答