代码(基于Numpy C-Api example gives a SegFault。他们跟踪的教程链接已经失效,我还没有找到好的教程):
#include <Python.h>
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#include "numpy/arrayobject.h"
int main()
{
Py_Initialize();
import_array();
int typenum;
PyArrayObject *alpha;
PyObject *a = NULL;
int n = 100;
int nd = 1;
int dims[nd];
dims[0] = n;
a= PyArray_FromDims(nd, dims, NPY_DOUBLE);
alpha = (PyArrayObject*) a;
typenum = PyArray_DIMS(alpha)[0];
printf("%i",typenum);
PyRun_SimpleString("print 'Hello Python C/API'");
Py_Finalize();
return 0;
}
^{pr2}$
在a= PyArray_FromDims(nd, dims, NPY_DOUBLE);
上给出一个segfault。在
我在一个虚拟环境里,本激活了。“…”提供了到我的虚拟环境的路径,其中numpy作为子目录存在,并且已经使用pip install-enmpy进行了安装。在
目前没有回答
相关问题 更多 >
编程相关推荐