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

Posted 小大大小

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)

 

以上是关于python代码在linux终端中执行报错:Unable to init server: Could not connect: Connection refused的主要内容,如果未能解决你的问题,请参考以下文章