Putty: _tkinter.TclError: no display name and environment variable diplay

Related question: Mac OS X: _tkinter.TclError: no display name and no $ DISPLAY environment variable

The above problem has the same problem, but the answer to this question is not applicable to me.

a.py

from Tkinter import * root = Tk() canvas = Canvas(bg='white', width = 200, height = 200) canvas.pack() canvas.create_line(0, 0, 199, 199, fill="blue", width = 5) canvas.create_line(0, 199, 199, 0, fill="blue", width = 5) canvas.update() canvas.postscript(file = "x.ps") root.mainloop() 

a.py is on a remote server

This works great when I connect to the server via VNC and start it.

But when I connect to the server via Putty on the windows and start it, it gives me "no display name and environment variable diplay"

1) Is it possible to run this through Putty?

2) Can python find out if the connection is connected with putty and maybe raise my own error instead of TclError?

0
python putty
source share
1 answer

You need to start the X server on your Windows computer and then enable X11 forwarding in the putty session before logging in (see the Connection / SSH / X11 properties page in PuTTY). I used to use Xming , which is free and eXceed, which was not. After you have an X server on the computer that you are actually viewing and forwarding the X connection via the ssh link, it sets up the DISPLAY environment variable on the remote computer so that the X clients can communicate with the display server. Otherwise, without installing DISPLAY Tk will cause an error - as you can see.

+2
source share

All Articles