Djangoにて家計簿を実装しているのですが、
グラフを描画→画像で保存→HTMLで表示
という動作を数回行うと、下記のエラーが発生してしまいます。
グラフ部分を除外するとエラーが発生することはないので、グラフ部のどこかが悪いとは思うのですが、調べてみても解決策が見つかりません
##エラー
Exception ignored in: <bound method Image.del of <tkinter.PhotoImage object at 0x0000020B28F3F550>>
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\tkinter_init_.py", line 3501, in del
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <bound method Image.del of <tkinter.PhotoImage object at 0x0000020B28F3FC18>>
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\tkinter_init_.py", line 3501, in del
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <bound method Image.del of <tkinter.PhotoImage object at 0x0000020B2D29B2E8>>
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\tkinter_init_.py", line 3501, in del
self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Tcl_AsyncDelete: async handler deleted by the wrong thread
##グラフ部のプログラム
def plot_graph(cs):
data=cs.values()
label=cs.keys()
plt.style.use('ggplot') plt.rcParams.update({'font.size':15}) size=(9,5) col=cm.Spectral(np.arange(len(data))/float(len(data))) plt.figure(figsize=size,dpi=100) plt.pie(data,colors=col,counterclock=False,startangle=90,autopct=lambda p:'{:.1f}%'.format(p) if p>=5 else '') plt.subplots_adjust(left=0,right=0.7) plt.legend(label,fancybox=True,loc='center left',bbox_to_anchor=(0.9,0.5)) plt.axis('equal') plt.savefig('blog/static/images/simple.png',bbox_inches='tight',pad_inches=0.05) plt.cla() plt.clf() plt.close()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/28 09:59