1
//testNumpy.c
#include<Python.h>
#include<numpy/arrayobject.h>
#include<stdio.h>
int main(){
    printf("import_array\n");fflush(stdout);
    import_array();
    printf("import_array done\n");fflush(stdout);
}

$ gcc -I/usr/include/python2.6 -lpython2.6 testNumpy.c&&./a.out
import_array
Segmentation fault (core dumped)

What could I possibly be doing wrong on such a simple program? I'm tearing my hair out :-)

1 Answer 1

4

For starters, you did not initialize Python properly. Call Py_Initialize() before trying to initialize NumPy.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.