[cairo] Dynamic module not initialized properly

Simon Sapin simon.sapin at exyr.org
Sat May 25 02:22:15 PDT 2013


Le 10/05/2013 22:46, Vincent de Vos a écrit :
> After building pycairo using GNU Make (I did not use the WAF installer
> because it kept building with errors:
> http://lists.cairographics.org/archives/cairo/2013-May/024295.html)
> .
> configure --prefix=/home/vdevos/pycairo
> make
> make install
>
> It is now included in my PYTHON_PATH using:
> export PYTHONPATH=/home/vdevos/pycairo/lib/python2.6/site-packages/cairo
>
> Then when I open python2.6 on my console and try to import the _cairo
> module I get the following error...
>
> Python 2.6.4 (r264:75706, Dec  5 2009, 21:18:28)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import _cairo
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> SystemError: dynamic module not initialized properly
>
> Does anyone have an idea how to fix this?

Hi,

The _cairo.so file is made to be imported (implicitly) as "cairo._cairo" 
as its Python name. But it’s really an implementation detail. You should 
also have an __init__.py file next to it that contains something like 
"from ._cairo import *" (Note that this is a relative import.)

You’re not supposed to have …/site-packages/cairo in your PYTHONPATH. 
"import cairo" should instead import the cairo/__init__.py file, which 
in turn imports cairo._cairo.

Cheers,
-- 
Simon Sapin


More information about the cairo mailing list