I managed to work past this problem. It seems that some modules have problems when their initialization routines are called more than once, and numpy
is one of those. The solution is to call Py_Finalize()
only once at the very end of the program. Py_Initialize()
can be called as many times as you want, as if Python is already initialized, Py_Initialize()
is a non-op ...
And also, discovered that this solution turns the application faster since python doesn't need to restart every time there's a call to some of its function.
More information about it here