0

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
cubick
  • 135

2 Answers2

1

The latest version of WSL2 has built-in support for GUI apps on Linux.

From the official documentation

Existing WSL install

If you already have WSL installed on your machine, you can update to the latest version that includes Linux GUI support by running the update command from an elevated command prompt.

Select Start, type PowerShell, right-click Windows PowerShell, and then select Run as administrator.

Enter the WSL update command:

wsl --update

You will need to restart WSL for the update to take effect. You can restart WSL by running the shutdown command in PowerShell.

wsl --shutdown
thehale
  • 111
-1

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.