Turtle returns error about tkinter enviroment variable and display name

Viewed 111

I have this error and I don't know what to do. I don't think that something is missing. I installed tkinter. I have python 3.9. Running Ubuntu in WSL. It seems that something's missing. I'm fairly new to python and all of these stuffs, so I would like to ask you to explain the solutions very detailed.

Traceback (most recent call last):
  File "h.py", line 14, in <module>
    main()
  File "h.py", line 9, in main
    turtle.begin_fill()
  File "<string>", line 6, in begin_fill
  File "/usr/lib/python3.8/turtle.py", line 3813, in __init__
    Turtle._screen = Screen()
  File "/usr/lib/python3.8/turtle.py", line 3663, in Screen
    Turtle._screen = _Screen()
  File "/usr/lib/python3.8/turtle.py", line 3679, in __init__
    _Screen._root = self._root = _Root()
  File "/usr/lib/python3.8/turtle.py", line 435, in __init__
    TK.Tk.__init__(self)
  File "/usr/lib/python3.8/tkinter/__init__.py", line 2270, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Thanks in advance.

1 Answers

Running a GUI through WSL will require 2 things.

  1. You will need to install and run an X Server. One example of this is XMing.
  2. You will need to actually set the environment variable DISPLAY. You can do this by: export DISPLAY=localhost:0.0
Related