I'm trying to import sklearn in a C application with embedded python and it falls into what appears to be some sort of recursive loop. Has anyone encountered this before and found a solution?
I've created the very simple application below. When I execute it, I get a "FutureWarning", and then it appears that the application starts again. Executing a python script with this import line has no problems; neither does executing it from the Python REPL.
int
main(int argc, char *argv[])
{
printf("%s\n",argv[0]);
wchar_t *program = Py_DecodeLocale(argv[0], NULL);
if (program == NULL) {
fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
exit(1);
}
Py_SetProgramName(program); /* optional but recommended */
Py_Initialize();
PyObject *pName, *pModule;
pName = PyUnicode_DecodeFSDefault("sklearn");
pModule = PyImport_Import(pName);
Py_Finalize();
PyMem_RawFree(program);
return 0;
}
I get the following output repeated over and over again until I exit:
./a
/home/wisp/anaconda3/envs/mpl-test/lib/python3.5/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (is
)) and will change.
_nan_object_mask = _nan_object_array != _nan_object_array
/home/wisp/test-py/a
/home/wisp/anaconda3/envs/mpl-test/lib/python3.5/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (is
)) and will change.
_nan_object_mask = _nan_object_array != _nan_object_array
/home/wisp/test-py/a
/home/wisp/anaconda3/envs/mpl-test/lib/python3.5/site-packages/sklearn/utils/fixes.py:313: FutureWarning: numpy not_equal will not check object identity in the future. The comparison did not return the same result as suggested by the identity (is
)) and will change.
_nan_object_mask = _nan_object_array != _nan_object_array
..
..
..
The warning is expected based on my observations of the script and REPL; the continuous output is not.