import matplotlib matplotlib.use('Agg')
将上述语句放在python文件函数的最开头处。
并在终端添加如下命令:
export DISPLAY=mymachine.com:0.0