Python 3.x 使用Cython使用numpy lib编译Python函数

Python 3.x 使用Cython使用numpy lib编译Python函数,python-3.x,cython,cpython,cythonize,Python 3.x,Cython,Cpython,Cythonize,我有python函数,使用numpy模块。比如说 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..

我有python函数,使用numpy模块。比如说

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;
}
当我运行exe文件时,我遇到了一个错误

Exception NameError: "name 'np' is not defined" in 'test.test' ignored
如何使用numpy lib编译所有文件

相关问题:及相关问题:及
Exception NameError: "name 'np' is not defined" in 'test.test' ignored