[Numpy-discussion] CAPI segfault running python embedded
Fri Jun 20 08:30:33 CDT 2008
David Cournapeau wrote:
> Lane Brooks wrote:
>> I have successfully written several extension modules that use the numpy
>> CAPI to manipulate numpy arrays. I have to say numpy is great.
>> I am now having a problem, however, when calling numpy capi functions
>> when running python embedded in a third party, closed source,
>> application. It segfaults whenever I make any PyArray* function call.
>> Any ideas on why that might be happening?
> You most likely forgot to call import_array functions when initializing
> your extension (the PyMODULE_INIT function): with python, extensions
> which define new C-API does it through an array of function pointers,
> which is garbage before you call import_array. I have never used
> embedded python, so I don't know how initialization works there, but
> that should be similar I guess.
> Numpy-discussion mailing list
Your exactly right. I was side-tracked by the fact that this was
embedded python (which is not really that different) and thought was
thinking it was an environmental condition. Adding the import_array()
cleared the problem up immediately. Thanks for the help.
More information about the Numpy-discussion