在下面的代码的第二次调用,我的应用程序段错误,所以我想我错过了一些东西:
Py_Initialize();
pName = PyString_FromString("comp_macbeth");
pModule = PyImport_Import(pName);
Py_DECREF(pName);
if(pModule == NULL) {
PyErr_Print();
Py_Finalize();
return;
}
pFunc = PyObject_GetAttrString(pModule, "compute");
/* pFunc is a new reference */
if (!pFunc || !PyCallable_Check(pFunc) ) {
PyErr_Print();
Py_Finalize();
return;
}
Py_Finalize();
comp_macb.py正在导入numpy。如果我删除numpy导入,一切都很好。这是一个numpy bug,还是我错过了一些关于进口的东西?