python代码在linux终端中执行报错:Unable to init server: Could not connect: Connection refused

python代码在linux终端中执行时报错:

Unable to init server: Could not connect: Connection refused
Unable to init server: 无法连接: Connection refused

解决办法:

在要执行的python文件里加入以下两句代码:

切记:在最开头添加。

import matplotlib
matplotlib.use('Agg')

 

posted @ 2019-10-16 10:54  小大大小  阅读(17238)  评论(0编辑  收藏  举报