5

I think my code is nothing wrong. Because it's very simple, it worked very well on my Windows PC, and shows no error message at all.

from turtle import Turtle, Screen

turtle = Turtle()
screen = Screen()

screen.exitonclick()

However, on Pycharm on my Monterey M1 Macbook, the Python Turtle Graphics window shows nothing but black screen and scroll bars.

Python Turtle Graphics window with black screen and scroll bars

I think the application called python.app is something wrong. That's why I updated python with brew and re-installed Pycharm, but nothing has changed.

Does anyone know how to fix this? Thank you.

Iñigo González
  • 3,735
  • 1
  • 11
  • 27
Brian
  • 51
  • 1
  • 3
  • Can you expand your example code to attempt actually using the turtle/screen? For example, `s.bgcolor("pink")`. As written, it's unclear whether the turtle package isn't working for you here. Might be you just haven't told it to do anything and the default background colors are different. – Cory Petosky Nov 14 '21 at 02:29
  • 1
    If anyone runs my example code they should see a window with white background and a black arrow-shaped turtle. Thank you for your comment. I've just tried expanding code with `screen.bgcolor("pink")` and nothing happened. I find my other well-run turtle based projects on my previous PC not working on this Monterey Mac. – Brian Nov 14 '21 at 02:45
  • 1
    Does this code work if run in a python interpreter directly in the terminal? Is it possible this is a PyCharm-specific issue? If so I recommend editing the question (especially title) to reflect that. – Cory Petosky Nov 14 '21 at 02:47
  • OMG Thank you so much! Problem solved! I tried in the terminal and it didn't work. There was a problem with the python interpreter. So I changed to the latest 3.9 and it works! Really thank you for your kind comments – Brian Nov 14 '21 at 05:04

4 Answers4

7

have you tried to install the latest version of python? cause I'm facing the same problem earlier. I tried to install the latest python version and it just works like a charm now.

  • 5
    This may start with a question, but I think it contains the correct answer: update your python. I had the same problem on an M1 Monterey Macbook and was using Python 3.8.9. I updated to 3.10.1 and can attest that it does indeed "work like a charm." – majorobot Jan 08 '22 at 17:22
4

change the interpretepycharm interpreterr to 3.9 or 3.10 in pycharm.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 23 '22 at 06:02
3

Updating the interpreter will help fix the issue as it did in my M1 Mac and without needing to make a new project. However, there are a few extra steps needed to make sure it's compatible with your M1 chip.


Quick Steps:

  1. Download the latest Python version (Make sure the download link is labeled as "macOS 64-bit universal2 installer" as it'll be fully compatible with your M1 Mac)
  2. After installing the interpreter, open Pycharm -> Preferences -> Project: [Your Poject's Name] -> Python Interpreter
  3. Click the Options button (Gear Button) next to the Python Interpreter Box and select "Add..."
  4. Make sure "New Environment" is selected
  5. Select any empty folder (or make one) to store your interpreter (I chose to store it in Documents in the "Personal Python Interp" folder)
  6. For "Base Interpreter: ", "select the button with the three dots and paste /Applications/Python 3.10/IDLE.app/Contents/MacOS/Python, then press "OK" (IMPORTANT: Your Python version number may be different so update the "Python 3.10" to the python folder name found in "Applications")
  7. Check both boxes for "Inherit global site-packages" and "Make available to all projects" (UNLESS you have specific interpreters for other projects)
  8. If any, re-download any Python Packages you may need onto this interpreter

The turtle screen should be now fixed! I hope this helped!

Gerardo B.
  • 71
  • 4
  • 1
    This (update to python 3.10) worked for me too on a MacBook Air M1. I initially had python3.9 installed in /usr/bin/python3, and now I have python3.10 installed under /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 and now turtle works! I have idle3 now too, which I didn't before, so I guess my old python install was not the best of installations for some reason. :). Thank you! :) – Will Oct 05 '22 at 12:56
1

I don't think it has anything to do with the M1 processor. I have an M1 processor and had the same problem. My solution: Create a new project in Python. Previously configured interpreter Select Python 3.10 (the latest installed version). Click the button with the three dots ... Go to the directory of Python 3.10 (current version). IDLE.app -> Contents -> MacOS and -> Select Python. For me it looks like this:

/Applications/Python 3.10/IDLE.app/Contents/MacOS/Python

Then it works for me.

Johannes
  • 11
  • 1