On Wed, Mar 13, 2013 at 9:43 PM, Oliver King <oliver.afr...@gmail.com>wrote:
> Hi,
>
> I have a library which uses matplotlib to produce some plots. This library
> is called by a thread. However, python crashes with this error when it
> tries to plot something:
>
> Tk_MacOSXSetupTkNotifier: first [load] of TkAqua has to occur in the main
> thread!
>
> If I do as it says and call "window = Tkinter.Tk()" in the main thread
> before spawning the thread which calls the plotting routines, it works well
> until the program shuts down. When shutting down, I get a series of these
> messages (8 of them, to be precise):
>
> Exception RuntimeError: RuntimeError('main thread is not in main loop',)
> in <bound method PhotoImage.__del__ of <Tkinter.PhotoImage instance at
> 0x90fe260>> ignored
>
> Googling reveals to me that this is a problem with Tk: it doesn't like
> threading. I tried to force matplotlib to use a different backend with this
> command:
> matplotlib.rcParams['backend'] = something_else
> but it still crashes with the first error.
>
> Has anyone encountered this problem before? How did you overcome it?
>
>
Are you displaying the plots in the thread, or are you just saving the
plots directly? If you are saving them directly, then you can set your
backend to be "Agg" and get rid of the Tkinter.Tk() call (and probably
should get rid of the import as well). That way, matplotlib won't load up
any gui toolkits at all.
Cheers!
Ben Root
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users