Error When Running Tkinter in Python " No Display Name and No $Display Environment Variable" While Running the Code
The Error Message Is: Traceback (Most Recent Call Last): File "", Line 1, in File "/Usr/Lib/Python3.8/Tkinter/__Init__. Py", Line 2261, in __Init__ Self. Tk =...
The error message is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/tkinter/__init__.py", line 2261, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
1 Answer
The solution that worked for me was to export DISPLAY=:0, or export DISPLAY=:0.0 may work also.
If either of those work, add them to ~/.profile to make it persistent.