Error when running tkinter in python " no display name and no $DISPLAY environment variable" while running the code
Matthew Barrera
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 3 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.