Sup,
- I am simply trying to use Tkinter (a Python GUI creator) to create a GUI on my Raspberry Pi.
- To start, I only want a GUI to show up on my screen. That's it!
- The code DOES work on my PC
- The code does NOT work on my Raspberry Pi
The entire script looks as follows:
(works on my PC, bringing up an empty GUI)
import Tkinter
root = Tkinter.Tk()
root.mainloop()
Trying to run the program in terminal as follows:
sudo python GUI.py
Produces the following error:
Traceback (most recent call last):
File "GUI.py", line 4, in root = Tkinter.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1817, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Does anybody have any idea how I can resolve this issue? The error is produced under all of the following conditions:
- Direct HDMI to computer monitor
- DSI connection to touchscreen LCD
- SSH on computer monitor
For reference, if I type the following into my terminal:
echo $DISPLAY
An empty string gets printed, so I believe therein lies the problem
The following commands don't work either, which might shed light on the problem:
sudo apt-get update
startx
sudo
? Are you calling script from ssh ? If yes, try settingDISPLAY
varible byexport DISPLAY=:0
and then running it. Hope it helps.startx
and try doing it.