[Matplotlib-users] Simultaneous plots with Matplotlib "QObject/thread" error

Eric Firing efiring at hawaii.edu
Fri Sep 9 03:16:16 EDT 2016


On 2016/09/08 8:40 PM, John Robson wrote:
> Hi all,
>
> I have some Flask pages that plot charts using Matplotlib, they work
> very well, but when running them simultaneously they break the site,
> with errors like:
>
> "QObject: Cannot create children for a parent that is in a different
> thread."
>
> "QObject::~QObject: Timers cannot be stopped from another thread"
>
> I wonder how to safely use Matplolib with Flask (with several
> simultaneous users plotting charts all the time)?

I suspect the problem is that matplotlib is running with the qt4agg backend.

When plotting for a web app like that, you need to make sure the backend 
is set to the agg backend.  You can do that in a matplotlibrc file or 
directly in the plotting script, immediately after importing matplotlib 
and before importing pyplot (if you use pyplot at all).

Eric

>
> Thank you,
> John



More information about the Matplotlib-users mailing list