我使用numpy模块具有python函数。例如
import numpy as np
cdef public void test():
x = np.linspace(-4, 4, shapness)
我有 main.c 函数,调用了 test 函数。
#include <Python.h>
#include "test.h"
int main (int argc, char **argv)
{
printf ("Initializing Python Runtime...\n");
Py_Initialize ();
inittest();
test();
printf ("Cleanup...\n");
Py_Finalize ();
return 0;
}
我正在使用 cython
进行全部编译cython test.pyx -o test.c
gcc -o app main.c test.c `python-config --includes --ldflags`
当我运行exe文件时,出现错误
Exception NameError: "name 'np' is not defined" in 'test.test' ignored
我如何使用numpy lib进行编译。