MacBook Air MacOS Mojava (10.14.6) crashes when python turtle module

MacBook Air MacOS Mojava (10.14.6) crashes when python turtle module is executed using python Python 3.9.0 (v3.9.0:9cf6752276)

from turtle import Turtle

laura = Turtle()

laura.color('red')

laura.shape('turtle')


When I execute the code above, a small python launcher appears and then, my MacBook either restarts, freezes until I restart it using the power button or displays a white screen with black lines (static screen) before restarting. I use IDLE 3.9 to type up the code, however when I run it using python launcher, it crashes as soon as laura = Turtle() is executed. However on another admin on the same MacBook, it does not crash or restart but works successfully.


Please advice me on how to fix this issue.


Thank you.

Posted on Feb 18, 2021 11:24 AM

Reply
2 replies

Feb 18, 2021 12:24 PM in response to afsah_257

I believe I responded to this question in 2020. I can confirm that the following Python script runs just fine in Python 3.9.1 on macOS 11.2.1 (M1), and on macOS 10.14.6. Copy and paste the following code into a proper programmer's editor (e.g. BBEdit) that will not destroy the Python indent:


#!/usr/bin/env python3

from turtle import Turtle, mainloop


def main():

    laura = Turtle()
    laura.color('red')
    laura.shape('turtle')


if __name__ == '__main__':
    main()
    mainloop()


You save this in a file named turt.py on your Desktop. Launch the Terminal application and enter the following:


cd ~/Desktop
chmod +x ./turt.py
./turt.py



Of course, you must have your PATH environment variable properly configured so that the python3 executable is found. If you installed it via the Python.org installer, it would have prefaced your Bash PATH with the path to the Python 3.9 executables in its library.

Feb 18, 2021 3:57 PM in response to VikingOSX

Hi,


Thank you very much! It worked when I used the mentioned code in Atom on macOS Big Sur. I also installed python 3.9.1.


Just to be confirm, I should use and incorporate my codes in this python script whenever I have to use Turtle class.


Yes I saw this yesterday as I did not receive any email regarding a reply to my query. However as I was unable to reply to the thread, I had to repost the question.


Thank you for all the help and guidance!





This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

MacBook Air MacOS Mojava (10.14.6) crashes when python turtle module

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.