[C++-sig] Embedding/Extending Python at the same time...

Hugh Macdonald hugh-m at moving-picture.com
Fri Nov 19 17:34:49 CET 2004


I posted this on comp.lang.python, but then found this mailing list, so I hope it's not considered bad etiquette to post in both places....

I've got a slight problem... and I'm stuck as to where to go with it...

I'm running on Redhat7.2, using Python 2.2.2

I've got a compiled module that I wrote almost a year ago - it works fine, and I've never had any problems with it...

I also did an extension to a plugin (Shake) using Python, so the plugin loads a python module and calls various functions in there....

all in all, fine - I thought I had my head around the system, and there were no problems...

However, I've just hit a problem...

If, in my plugin code, I import a module that is pure python, I'm fine. However, if I import my own compiled module, then I start having problems....

Initially, the module was compiled without linking to the actual python library. When I run the plugin, it fails, and PyErr_Print() prints out:

Traceback (most recent call last):
  File "/usr/people/hugh-m/dev/apps/hub/python/modules/noarch/hubdbremote.py", line 19, in ?
    import hub
ImportError: /usr/people/hugh-m/dev/apps/hub/python/modules/linux.redhat7.2.i386/hub.so: undefined symbol: PyFloat_Type


If I modify the SConstruct file so that the module links to the python library, it gives the following error:

Fatal Python error: Interpreter not initialized (version mismatch?)

Any idea what I could do to get around either of these?

Should python modules be compiled with the library linked in?

The plugin is compiled with gcc3.2.1 (needed because it's a Shake plugin), and the module is compiled with gcc2.96 (because that is what Python needs it to be). Is this my issue? If so, how can I get around it?


Any suggestions most welcome... and apologies for the large number of questions..

Cheers

-- 
Hugh Macdonald
The Moving Picture Company



More information about the Cplusplus-sig mailing list