Krayons Krayons - 4 months ago 36
Python Question

Installing pycairo under ubuntu

For some reason I can't get python to find cairo.

When I did ./waf configure I got

Setting top to : /home/user/pycairo/py2cairo-1.10.0
Setting out to : /home/user/pycairo/py2cairo-1.10.0/build_directory
Checking for 'gcc' (c compiler) : ok
Checking for program python : /usr/bin/python
Checking for python version : (2, 7, 2, 'final', 0)
Checking for library python2.7 : yes
Checking for program python2.7-config : /usr/bin/python2.7-config
Checking for header Python.h : yes
Checking for program pkg-config : /usr/bin/pkg-config
Checking for 'cairo' >= 1.10.0 : yes
PREFIX : /usr/local
LIBDIR : /usr/local/lib

So next I ran ./waf install.


import cairo
ImportError: No module named cairo

Now I am pretty stumped on what to do next.
I checked /usr/local/lib/python2.7/site-packages and it is there but that is the only package there. I also noticed "dist-packages" which I think that is where it's meant to go?

any help is greatly appreciated.


What is wrong with using the packaged version, with full Ubuntu support?

Python bindings for the Cairo vector graphics library

Python Cairo bindings for the GObject library

The "latest" way of using Cairo should be via gobject introspection (second package):

from gi.repository import cairo

which uses mostly auto-generated API from the GI repository that is consistent across various programming languages.