pycairo on kubuntu karmic 9.10

16 views
Skip to first unread message

King

unread,
Feb 9, 2010, 10:48:44 AM2/9/10
to wxPython-users
I am newbie to linux and tried installing pycairo using python
setup.py install method as explained here:
http://www.wxpython.org/docs/api/wx.lib.wxcairo-module.html

KPackageKit shows that libcairo2 1.8.8-2ubuntu1 (i386) is installed.

While using "python setup.py install" I am getting this error:
/bin/sh: pkg-config: not found

Error: cairo >= 1.8.8 not found

Could somebody point me out what's missing here?

kubuntu 9.10 Karmic
python 2.6.4

Robin Dunn

unread,
Feb 9, 2010, 4:10:13 PM2/9/10
to wxpytho...@googlegroups.com


There's no need to build it yourself, just install it from the Ubuntu
repository.

sudo apt-get install python-cairo


--
Robin Dunn
Software Craftsman
http://wxPython.org

King

unread,
Feb 9, 2010, 11:24:46 PM2/9/10
to wxPython-users
Thanks Robin,

Library is installed but lots of errors and segfaults

First:

ctx = cairo.GraphicsContext.Create(mdc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 915, in Create
ctx = wx.lib.wxcairo.ContextFromDC(dc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 115, in ContextFromDC
drawable = voidp( dc.GetGdkDrawable() )
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 71, in voidp
return ctypes.c_void_p(int(ptr))
TypeError: int() argument must be a string or a number, not 'NoneType'

Second:

python: /build/buildd/cairo-1.8.8/src/cairo.c:87: _cairo_error:
Assertion `(status != CAIRO_STATUS_SUCCESS && status <=
CAIRO_STATUS_INVALID_WEIGHT)' failed.
Aborted

Prashant

#---- System Information ----#
GUI2Exe Version: 0.5.0
Operating System: Linux 2.6.31-14-generic i686
Python Version: 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1]
wxPython Version: 2.8.10.1 (gtk2-unicode)
wxPython Info: (__WXGTK__, wxGTK, unicode, gtk2, wx-assertions-off,
SWIG-1.3.29)
Python Encoding: Default=UTF-8 File=UTF-8
wxPython Encoding: utf-8
System Architecture: 32bit i686
Byte order: little
Frozen: False
#---- End System Information ----#

King

unread,
Feb 9, 2010, 10:50:26 PM2/9/10
to wxPython-users
Thanks Robin

Library is successfully installed but here are few errors:

ctx = cairo.GraphicsContext.Create(mdc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 915, in Create
ctx = wx.lib.wxcairo.ContextFromDC(dc)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 115, in ContextFromDC
drawable = voidp( dc.GetGdkDrawable() )
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 71, in voidp
return ctypes.c_void_p(int(ptr))
TypeError: int() argument must be a string or a number, not 'NoneType'


another one:
(python:2115): Gdk-CRITICAL **: gdk_cairo_create: assertion
`GDK_IS_DRAWABLE (drawable)' failed.


Prashant

#####################################


Operating System: Linux 2.6.31-14-generic i686
Python Version: 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1]
wxPython Version: 2.8.10.1 (gtk2-unicode)
wxPython Info: (__WXGTK__, wxGTK, unicode, gtk2, wx-assertions-off,
SWIG-1.3.29)
Python Encoding: Default=UTF-8 File=UTF-8
wxPython Encoding: utf-8
System Architecture: 32bit i686
Byte order: little
Frozen: False

#####################################

King

unread,
Feb 10, 2010, 11:32:22 AM2/10/10
to wxPython-users
Here is one more and I think this one is causing crash.

File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 1152, in SetFont
font = GraphicsFont.CreateFromFont(font, colour)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 413, in CreateFromFont
f._fontface = wx.lib.wxcairo.FontFaceFromFont(font)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
wxcairo.py", line 164, in FontFaceFromFont
fontface =
pycairoAPI.FontFace_FromFontFace(ctypes.c_void_p(fontfaceptr))
cairo.Error: <unknown error status>
python: /build/buildd/cairo-1.8.8/src/cairo-font-face.c:191:
cairo_font_face_destroy: Assertion `((*&(&font_face->ref_count)-
>ref_count) > 0)' failed.
Aborted

Prashant

Robin Dunn

unread,
Feb 11, 2010, 12:50:28 AM2/11/10
to wxpytho...@googlegroups.com

It seems to be working okay here with my tests. There have been a few
changes recently with the GTK specific parts of the code in wxcairo.py,
you may want to try getting the latest version from SVN. If that
doesn't help then send us a sample that shows the problem.

King

unread,
Feb 11, 2010, 2:02:29 AM2/11/10
to wxPython-users
I would try to post a sample app ASAP.

I tried the new wxcairo.py from svn.

Problem 1.

The function "_findCairoLib" in *NEW* wxcairo is not able to find
cairo libs and raising an error.

I have replaced "_findCairoLib" function from *OLD* library into *NEW*
one. At least now there is no missing library error.

Application is getting crashed raising an error:

Just to look at:


python: /build/buildd/cairo-1.8.8/src/cairo.c:87: _cairo_error:
Assertion `(status != CAIRO_STATUS_SUCCESS && status <=
CAIRO_STATUS_INVALID_WEIGHT)' failed.
Aborted

I am not getting anything else and it's difficult to create a sample
app to reproduce the problem.
Right now I am investigating more and get back to you ASAP.

Thanks

Prashant

King

unread,
Feb 11, 2010, 2:59:01 AM2/11/10
to wxPython-users
Ok Here is first test:

import wx
import wx.lib.graphics as Cairo
import wx.lib.wxcairo as wxcairo

class DemoApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers() # called so a PNG can be saved
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
font.SetPointSize(12)
# Render a bitmap using MemoryDC.
width, height = 100, 100
size = width, height
colorBitmap = wx.EmptyBitmapRGBA(size[0]+1, size[1]+1)#, 0, 0,
0, 0)
# Prepare the bitmap using cairo & cairo image surface
surface = wxcairo.ImageSurfaceFromBitmap(colorBitmap)
ctx = Cairo.GraphicsContext.CreateFromSurface(surface)

# Imagine this as a onDraw/onPaint function where you are
continuously setting
# different fonts and drawing texts using it.
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")
ctx.SetFont(font, "blue")

ctx.DrawText("wxPython Rocks!!!", 0, 45)
ctx.SetBrush(wx.Brush("red"))
ctx.DrawRectangle(10,10,25,25)

# Save file
colorBitmap.SaveFile("text.png", wx.BITMAP_TYPE_PNG)


return True

if __name__ == "__main__":
print "about to initialize the app"
app = DemoApp(0)
app.MainLoop()

Error:


python: /build/buildd/cairo-1.8.8/src/cairo-font-face.c:191:
cairo_font_face_destroy: Assertion `((*&(&font_face->ref_count)-
>ref_count) > 0)' failed.
Aborted

Prashant

Robin Dunn

unread,
Feb 11, 2010, 9:46:36 PM2/11/10
to wxpytho...@googlegroups.com
On 2/10/10 11:02 PM, King wrote:
> I would try to post a sample app ASAP.
>
> I tried the new wxcairo.py from svn.
>
> Problem 1.
>
> The function "_findCairoLib" in *NEW* wxcairo is not able to find
> cairo libs and raising an error.
>
> I have replaced "_findCairoLib" function from *OLD* library into *NEW*
> one. At least now there is no missing library error.

Sorry I forgot to mention that change, see
http://trac.wxwidgets.org/ticket/11673. I'm working on a fix that will
still solve the problem the patch was intended to fix, but also fall
back to the old way in the other cases.


Ok, that's done and the crashing bug is fixed too. The refcount on the
fontface object needed to be incremented.

http://trac.wxwidgets.org/changeset/63469

King

unread,
Feb 11, 2010, 3:14:28 AM2/11/10
to wxPython-users
In one more situaton, i am getting this error:

dc.SetFont(self.boldFont, wx.BLACK)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 1156, in SetFont
self._font = GraphicsFont.CreateFromFont(font, colour)


File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/
graphics.py", line 413, in CreateFromFont
f._fontface = wx.lib.wxcairo.FontFaceFromFont(font)
File "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/

wxcairo.py", line 173, in FontFaceFromFont
fontface = pycairoAPI.FontFace_FromFontFace(fontfaceptr)
cairo.Error: <unknown error status>

(python:2528): Gdk-CRITICAL **: gdk_draw_drawable: assertion
`GDK_IS_DRAWABLE (drawable)' failed

Prashant

Robin Dunn

unread,
Feb 14, 2010, 2:25:05 AM2/14/10
to wxpytho...@googlegroups.com


What is the situation?

Reply all
Reply to author
Forward
0 new messages