python tkinter出错

方法:原因是没有X Server,可以在windows下安装Xming程序 不安装Xming的话,python GUI库tkinter无法使用,会报错,如下:_tkinter.TclError: couldn't connect to display "localhost:10.0"
python tkinter出错
方法:原因是没有X Server,可以在windows下安装Xming程序

不安装Xming的话,python GUI库tkinter无法使用,会报错,如下:

_tkinter.TclError: couldn't connect to display "localhost:10.0"2016-08-19
use a non-interactive backend (see What is a backend?) such as Agg (for PNGs), PDF, SVG or PS. In your figure-generating script, just call the matplotlib.use() directive before importing pylab or pyplot:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.savefig('myfig')
Note: This answer was in short mentioned in a comment. I put it
here as an answer to increase visibility since it helped me and I was
lucky enough that I decided to read the comments.
也就是在使用plt之前,调用一下matplotlib.use('TkAgg')即可,可以远程显示图像2019-06-11
mengvlog 阅读 8 次 更新于 2025-07-19 15:16:28 我来答关注问题0
檬味博客在线解答立即免费咨询

Python相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部