UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figur

1、问题:Backend TkAgg is interactive backend. Turning interactive mode on.

matplotlib的默认backend是TkAgg,而FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg这几个backend都要求有GUI图形界面的。

import matplotlib.pyplot as plt
Backend TkAgg is interactive backend. Turning interactive mode on.

plt.get_backend()
Out[3]: u'TkAgg'

解决方法:指定不需要GUI的backend(Agg, Cairo, PS, PDF or SVG

import matplotlib.pyplot as plt
plt.switch_backend('agg')

 

2、问题:UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure

解决方案:

import matplotlib

matplotlib.use('TkAgg')

 

参考:

https://www.icode9.com/content-4-32530.html

https://blog.csdn.net/neninee/article/details/87972040#commentsedit

 

 

你可能感兴趣的:(python)