python tkinter出错
用tkinter出现错误,用的是VNC,错误如下:(tkinter.TclError:couldn'tconnecttodisplay":1.0")...
用tkinter出现错误,用的是VNC,错误如下:
(tkinter.TclError: couldn't connect to display ":1.0") 展开
(tkinter.TclError: couldn't connect to display ":1.0") 展开
2个回答
展开全部
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')即可,可以远程显示图像
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')即可,可以远程显示图像
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询