Py_Initialize and Py_finalize and MatPlotlib

后端 未结 1 1784
臣服心动
臣服心动 2021-01-14 03:26

This is a known problem, but I want to ask the experts for the best way to solve it for me.

I have a project (Euler Math Toolbox), which runs Python as a script lan

相关标签:
1条回答
  • 2021-01-14 04:15

    To solve this, it would suffice to clear all variables and imports. I could live with not calling Py_Finalize. But how?

    Provided you properly release all references after each call, this should work fine. Just make sure to only call Py_Initialize a single time, and never call Py_Finalize. Run each "session" using a separate dictionary, and always decrement the reference counts properly when you're done with them (which will release those variables after running your code).

    On a side note - this is a common issue. Many other packages, such as numpy, or any package written using Boost::Python will exhibit the same behavior if you use Py_Finalize.

    0 讨论(0)
提交回复
热议问题