Я пытаюсь установить свою функцию, написанную на c (с помощью python3 setup.py install), но python вызывает ImportError: динамический модуль не определяет функцию экспорта модуля (PyInit_costFunction) ошибка!
costFunction.c:
static PyObject *costFunction(PyObject *self, PyObject *args)
{
return Py_BuildValue("d", 0); // or anything!
}
static PyMethodDef costFunction_methods[] = {
{"costFunction", (PyCFunction)costFunction, METH_VARARGS, "cost function"},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef costFunctionmodule = {
PyModuleDef_HEAD_INIT,"costFunction", NULL, -1, costFunction_methods
};
PyMODINIT_FUNC PyInit_costFunction(void)
{
return PyModule_Create(&costFunctionmodule);
}
setup.py:
from distutils.core import setup, Extension
setup(name='costFunction', version='1.0', \
ext_modules=[Extension('costFunction', ['costFunction.c'],include_dirs=['include'])])
внешняя библиотека: tinyexpr
я использую linux mint 18 с python 3.5.2
РЕДАКТИРОВАТЬ: версия python3-dev - 3.5.1-3.