From: John H. <jdh...@ac...> - 2004-12-18 16:18:28
|
>>>>> "Axel" == Axel Kowald <A.K...@gm...> writes: Axel> Hello, I have the following small problem when terminating a Axel> matplotlib script. Basically I do the following Axel> (interactive set to False): from pylab import * Axel> plot([1,2,3]) savefig('bla.ps') Axel> Now, this script does produce the PS file but then Axel> terminates with the error message: >> Fatal Python error: PyEval_RestoreThread: NULL tstate This >> application has requested the Runtime to terminate it in an Axel> unusual way. >> Please contact the application's support team for more >> information. This error has cropped up before in other contexts, always on win32, and I think a common cause is when you import the tk backend but do not start the tk mainloop (which is what show does), which is what I suspect you are doing since this is the default backend on win32. My guess is the bug will go away if you call "show" at the end of the script, but then you'll get the GUI window in addition to the ps file. I'm not sure if there is a fix for this. Basically, you want to create postscript output using the tk backend without having the tk window popup. Perhaps Todd has some ideas about what to do with tk internals to avoid this problem, but I don't know offhand. I'll try and take a look next week when I have access to a win32 box. Does the minimal script, which does nothing but "import pylab" replicate the problem? Do you know that you can run the script with -dPS from the shell to switch the backend? Then you'll get the PS, no GUI popup, no error, and you won't have to alter your script. You can also place an rc file in the directory where the script resides and make PS the default backend. When you want to switch to GUI mode, you can replace the backend parameter with TkAgg again. But you'll need the show in that case. If you get any additional information from some of the tests suggested above, let me know, because as I said this PyEval_RestoreThread has popped up in many contexts, including multiple calls to show or not calling it at all. I would like to fix these problems if possible so that it "just works". See related threads http://sourceforge.net/mailarchive/message.php?msg_id=10271482 http://sourceforge.net/mailarchive/message.php?msg_id=10114470 JDH |