Python C API crashes on 'import numpy' when initilizing multiple times
问题 While working with the Python C API, I found that the python interpreter crashes when initializing it a second time and executing import numpy after each initilization. Any other command (e.g. import time ) will do just fine. #include <Python.h> int main(int argc, char ** argv) { while(1){ printf("Initializing python interpreter...\n"); Py_Initialize(); if(PyRun_SimpleString("import numpy")) { exit(1); } printf("Finalizing python interpreter...\n"); Py_Finalize(); } return 0; } The above