Reputation: 81
I'm just starting with tkinter, not even running or preparing complex GUI apps, I have used this simple commands on other servers and it has worked perfectly, so the problem is probably in my installation.
My Linux version is 18.04 my python version is 3.6.5 .I have tried connecting from ssh, tried connecting from windows putty ( itś a remote server).
this is the code I try to execute:
from tkinter import *
potato = Tk()
potato.mainloop()
This is the error I get:
---------------------------------------------------------------------------
TclError Traceback (most recent call last)
<ipython-input-1-1a8e1fdc2509> in <module>()
1 from tkinter import *
----> 2 potato = Tk()
3 potato.mainloop()
/usr/lib/python3.6/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use)
2018 baseName = baseName + ext
2019 interactive = 0
-> 2020 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
2021 if useTk:
2022 self._loadtk()
TclError: no display name and no $DISPLAY environment variable
I'm kind of a noob, so please tell me any missing information you might need.
Upvotes: 0
Views: 877
Reputation: 736
Your code works properly don't worry about it.
In this case the error you are getting (no display name and no $DISPLAY environment variable
) is related to your SSH connection due to that the server is not able to find a display where to render your program.
If you want to use PuTTY and view the tkinter app in your windows machine (run a X server) you will need to specify that in the PuTTY configuration beforehand. In order to do that you just have to enable the X11 forwarding (in Connection > SSH > X11 > Enable X11 forwarding).
Upvotes: 1