[PyKDE] Using SIP modules from embedded Python

Phil Thompson phil at riverbankcomputing.co.uk
Mon Feb 19 13:34:32 GMT 2007


On Monday 19 February 2007 12:55 pm, Paul Giannaros wrote:
> Hi there,
> I have wrapped key bits of Kate's interface (as documented at
> http://developer.kde.org/documentation/library/3.5-api/kdebase-apidocs/kate
>/html/) with SIP. Firstly, thanks for SIP -- along with good documentation,
> ease of use, and Qt/KDE support it was a piece of cake.
> However, my intention is to use that library from within a C++ Kate Plugin.
> The plugin embeds Python and (so far) just attempts to import the
> SIP-created module. Doing so gives an ImportError, however, which I do not
> get if I just import the module from the interactive interpreter.
>
> The error is:
> ImportError: /usr/lib/python2.5/site-packages/sip.so: undefined symbol:
> _Py_ZeroStruct.
>
> Both my C++ plugin and my SIP extension link to python (the SIP extension
> does because if I don't I get a 'PyCObject_Type' undefined error when
> trying to import it).
>
> Another interesting thing is that If I isolate the importing code from the
> Kate plugin with a simple application, it imports fine.
>
> Any ideas what's going wrong?

There are a couple of things your plugin needs to do (for a Qt4 example see 
the new Designer plugin in current PyQt4 snaphots).

You need to make sure the Python shared library is loaded and that it exports 
all of its symbols.

You should also make sure you link against the Python shared library and not 
the static one.

Phil




More information about the PyQt mailing list