Python turtle module causes OS X to crash

巧了我就是萌 提交于 2019-12-13 11:59:03

问题


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?


回答1:


try and set the screen and mainloop

    window = turtle.Screen()
    window.setup(width,height)
    while True:
            window.update()
    window.mainloop()



回答2:


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



来源:https://stackoverflow.com/questions/57453645/python-turtle-module-causes-os-x-to-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!