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
  • 133
  • 5
vishnu dk
  • 1
  • 1
  • 1
  • 1
    WSL is a CLI environment - for WSL1 see [What's the easiest way to run GUI apps on Windows Subsystem for Linux as of 2018?](https://askubuntu.com/questions/993225/whats-the-easiest-way-to-run-gui-apps-on-windows-subsystem-for-linux-as-of-2018). WSL2 is somewhat different [How to set up working X11 forwarding on WSL2](https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2) – steeldriver Oct 02 '20 at 10:16
  • While support for Xorg is a planned feature for WSL, and support for GUI applications is planned some time after that, it's still unsupported. Please see the WSL FAQ on the topic: https://docs.microsoft.com/en-us/windows/wsl/faq#can-i-run-all-linux-apps-in-wsl – Nmath Oct 10 '20 at 05:18
  • 1
    Community Bot auto-bumped this question today, since it has no accepted answers. However, it's really a duplicate of *many* questions here. I'll start with [Can't Run GTK on WSL, Display Error](https://askubuntu.com/questions/897846/cant-run-gtk-on-wsl-display-error). I'd recommend closing this so that it doesn't get auto-bumped again. – NotTheDr01ds Jul 21 '21 at 12:33

2 Answers2

0

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
  • 101
  • 2
-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.