21

I'm working through Think Python chapter 4, where they tell you to type the following to see if you have the turtle module:

import turtle
bob = turtle.Turtle()

This is supposed to open a new window, but instead, it crashes my computer. I've seen it freeze my computer where I can't move the cursor or change windows, and I have to restart it. And I've also seen it close all my programs and re-open them.

I'm running Python 3.7 downloaded from Anaconda on a Macbook Air with Mojave version 10.14.6.

EDIT: When I run BenajahTX's suggestion below, I get this error message printed 16 times: CGSTrackingRegionSetIsEnabled returned CG error 268435459

Any clue what is causing this or how to fix it?

valerieo
  • 211
  • 2
  • 4
  • What is the exact error message you are getting when it crashes? – l'L'l Aug 12 '19 at 05:23
  • I don't get an error message. My computer will either freeze immediately and I have to force a restart or it closes all my programs. When I go back to the terminal, it says it was restored (e.g. [Restored Aug 12, 2019 at 10:44:28 AM]), but no error message. – valerieo Aug 12 '19 at 17:48
  • Actually, just tried BenajahTX's suggestion below, and got an error message: python[1808:86486] CGSTrackingRegionSetIsEnabled returned CG error 268435459 – valerieo Aug 12 '19 at 17:59
  • It seems to be a bug in `macOS`. There are others that report similar behavior when using `tkinter` and/or `py2app`. – l'L'l Aug 15 '19 at 04:44
  • Did you end up solving this problem? – huggie Sep 05 '20 at 07:47
  • Oh I solved by reinstalling Anaconda. Probably updating everything would suffice. – huggie Sep 05 '20 at 08:37

2 Answers2

1

try and set the screen and mainloop

    window = turtle.Screen()
    window.setup(width,height)
    while True:
            window.update()
    window.mainloop()
BenajahTX
  • 21
  • 4
  • 1
    I tried this, first in interactive mode, then in a script. In interactive mode, when I tried window = turtle.Screen(), it immediately restarted my computer. When I ran the entirety of what you suggested as a script, it also restarted my computer, but now I see this error message in the terminal printed 16 times: python[1808:86486] CGSTrackingRegionSetIsEnabled returned CG error 268435459 – valerieo Aug 12 '19 at 17:55
0

Try running the file in the terminal using the command:- $ python filename.py

I had the same issue and I was VS code extension Code Runner to run the python file, however, when I tried the terminal it worked and the mac OS was not crashing this time