0
import turtle
timmy = turtle.Turtle()
timmy.forward(100)

When I run this code, the Python Turtle Graphics window pops up on my screen, frozen. Right after that it crashes and leaves me confused.

Can someone please tell me how to stop it from crashing? Thanks!

ToTamire
  • 1,425
  • 1
  • 13
  • 23
YYCoding101
  • 1
  • 1
  • 1
  • It's probably a problem with the graphics backend. The `turtle` module's docs says it uses the `tkinter` module and you need a version of Python installed with Tk support to make it work. I was playing around with `turtle` in Spyder, and this same code kept crashing the IPython console with no window, until I changed the graphics backend in the Spyder settings to the Tkinter option. It's hard to say how to fix your specific case without any details, it may not be as easy as my case. – BatWannaBe Oct 03 '21 at 20:32

1 Answers1

1

I know I am fairly late but I have a solution. When you are done with all the commands you should add the following command:

turtle.done()

Adding in turtle.done() will let python know that turtle is done "drawing" and will prevent the program from becoming unresponsive and crashing. Overall your code should look as follows:

import turtle
timmy = turtle.Turtle()
timmy.forward(100)

I have tested this on three different versions of python. Python 3.6, 3.9 and 3.10

Antoine
  • 1,393
  • 4
  • 20
  • 26