简体   繁体   中英

Does Turtle need Tkinter?

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

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

Look into how to set environment variables, specifically $DISPLAY

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM