用matplot和seaborn作图,出现This application failed to start because not Qt platform plugin could be initialized的报错

发布时间 2023-11-30 19:49:47作者: 以后指定是大牛

用matplotlib和seaborn作图,出现这样的弹窗:

 尝试过增加环境变量的方法没有解决。使用了一种临时的解决方法:

import matplotlib
matplotlib.use('TKAgg')

如果不需要图形化界面,只需要运行后的参数可以使用:

import matplotlib
matplotlib.use('Agg')