import matplotlib; matplotlib.use('agg') 注意:要添加到所有matplotlib前面,否则不起作用 转载于:https://www.cnblogs.com/haiyang21/p/9924075.html