embedding python with numarray

Marc Schellens m_schellens at hotmail.com
Thu Mar 25 15:25:16 CET 2004


Using Python 2.3.3,
trying to embed python with numarray,
my C++ application crashes (segmentation fault) at "import_libnumarray()",
(I c&p the macro, its within the macro at:
PyObject *module =
PyImport_ImportModule("numarray.libnumarray");
)

when I:

    1.
       initalize python and numarray like:
    ...
       Py_Initialize();
       import_libnumarray();
    ...

    2 .
       load another module like:

         PyObject* pModule = PyImport_Import(pName);


    3.
    call Py_Finalize()
    and do 1. again.

The palce where it crashes is:
Objects/typeobject.c
line 3004:
if (basebase->tp_as_sequence == NULL)


If I call import_libnumarray() only once (ie calling Py_Initialize()
without import_libnumarray() the second time,
I cannot use numarray:

Traceback (most recent call last):
   File "/usr/local/gdl/gdl/test.py", line 5, in testfun
     print a
   File 
"/usr/local/lib/python2.3/site-packages/numarray/numarraycore.py", line 
660, in __str__
     return array_str(self)
TypeError: 'NoneType' object is not callable


Any suggestions?
How can numarray be restarted properly after a Py_Finalize() ?
Thanks,
marc




More information about the Python-list mailing list