Matplotlib - Tcl_AsyncDelete: async handler deleted by the wrong thread?

前端 未结 3 1803
暖寄归人
暖寄归人 2020-12-14 07:42

I\'m asking this question because I can\'t solve one problem in Python/Django (actually in pure Python it\'s ok) which leads to RuntimeError: tcl_asyncdel

3条回答
  •  渐次进展
    2020-12-14 08:02

    By default matplotlib uses TK gui toolkit, when you're rendering an image without using the toolkit (i.e. into a file or a string), matplotlib still instantiates a window that doesn't get displayed, causing all kinds of problems. In order to avoid that, you should use an Agg backend. It can be activated like so --

    import matplotlib
    matplotlib.use('Agg')
    from matplotlib import pyplot
    

    For more information please refer to matplotlib documentation -- http://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server

提交回复
热议问题