2
イムを定義していません(のpython3ではをsetup.py installを)が、PythonははImportErrorを上げる:動的モジュールは、モジュールのエクスポート機能(PyInit_costFunctionを定義していません。 ) エラー!のpython:はImportError:動的モジュールはCで書かれた私の機能をインストールしようとしているモジュールのエクスポート機能に
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私は、PythonでLinuxのミント18を使用しています3.5.2
EDIT: のpython3-devのバージョンは、最後に、私は汚いトリックを3.5.1-3