[Numpy-discussion] CAPI segfault running python embedded

Lane Brooks lbrooks at MIT.EDU
Fri Jun 20 09:30:33 EDT 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.
>
> cheers,
>
> David
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   
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.

Lane



More information about the NumPy-Discussion mailing list