Ubuntu 16.04,已安装Nvidia-docker,在运行TensorFlow容器,Python 2.7。
我想在容器内运行一个简单的Python代码,如下所示:
from tkinter import *
master = Tk()
canvas_width = 80
canvas_height = 40
w = Canvas(master,
width=canvas_width,
height=canvas_height)
w.pack()
y = int(canvas_height / 2)
w.create_line(0, y, canvas_width, y, fill="#476042")
mainloop()
但是当我运行它时,出现了这个错误
_tkinter.TclError: 没有显示名称和没有$DISPLAY环境变量
根据这个网站的内容 https://github.com/moby/moby/issues/8838,我将我的容器提交为一个镜像,并使用-e标志再次运行它:
-e DISPLAY=:0.0
但是出现了这个错误:
_tkinter.TclError: 无法连接到显示 :0.0
我没有使用ssh登录容器。有谁能给我建议吗?