Py_Initialize and Py_Finalize and MatPlotlib

R

Rene Grothmann

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 language. For this, a library module "python.dll" is loaded at run time, which islinked against "python27.lib". Then Py_Initialize is called. This all works well.

But Euler can be restarted by the user with a new session and notebook. Then I want Python to clear all variables and imports. For this, I call Py_Finalize and unload "python.dll". When Python is needed, loading and initializing starts Python again.

This works. But Python crashes at the first call, if MatPlotlib is importedin the previous session. It seems that Py_Finalize does not completely clear Python, nor does unloading my "python.dll". I tried unloading "python27.dll" (the Python DLL), but this does not help. Most likey, another DLL remains active, but corrupts during Py_Finalize.

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

PS: You may wonder, why I do not directly link euler.exe to Python. The reason is that this prevents Euler form starting, if Python is not installed, even if it is never needed.

Thanks for any answers! You duplicate your answer to renegrothmann at gmail, if you like. That would help me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top