-1

So I am new to python and I am working through a turtle racer tutorial. I have copied the code exactly and the tutorial shows the code working at this point (though not complete). Mine does not. I installed tkinter on my first error that mentioned it, but now I get this error. I have modified the code a few different ways (included the commented out section using tkinter). What should I do to fix this error and continue on with my tutorial? This is the error I am getting and This is the incomplete code for the racer

Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
  • Not positive but I believe `Turtle` is only compatible with either the x86 version of python. Make sure your not running the 64bit – TheLazyScripter Jan 29 '22 at 18:52
  • 4
    Hi and welcome to SO. It is important for the community that you *also* demonstrate that you are working to solve your issue. The best way to do that in my opinion is to include the **text** based version of the source code you have so far, even if it is not working quite right. – JonSG Jan 29 '22 at 18:53
  • 2
    [Please do not upload images of code/data/errors when asking a question.](http://meta.stackoverflow.com/q/285551) – martineau Jan 29 '22 at 19:16
  • Python's `turtle` module is implemented using `tkinter` — so yes, you need it. However you shouldn't need to install it yourself because nowadays it's included in Python's standard library. – martineau Jan 29 '22 at 19:18

3 Answers3

0

It seems like it is looking for an environment variable that is not set.

Look into how to set environment variables, specifically $DISPLAY

  • Could this be an issue since I am using windows subsystem for Linux instead of my actual linux machine? I code on both, but I started this on my windows machine because I was already on it when I found the tutorial. – hold_the_mike Jan 29 '22 at 19:06
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 29 '22 at 19:46
0

Yes, it requires tkinter, it needs the Tk window for your output. You may refer to this post for clarification: here

Also, this post here provides a good explanation on how turtle operates in two modes: standalone and embedded.

Blaco
  • 109
  • 8
0

Figured out the issue. I wasn't realizing the call back to the DISPLAY variable because I was too focused on the Tkinter problems and another user pointed out that part of the error.

I was coding on window's subsystem for linux which doesn't have a GUI. So I was just running code like I would on my actual linux machine without thinking. I ran the code on my linux machine that has a GUI and it worked without any tkinter code added in. It couldn't find the DISPLAY variable because there wasn't one on WSL.

Basically I just did something a bit dumb and realized my mistake. Thanks for the help, everyone!