[英]Python Turtle Graphics window shows nothing
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.
因为它非常简单,所以它在我的 Windows PC 上运行良好,并且根本没有显示错误消息。
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.然而,在我的 Monterey M1 Macbook 上的 Pycharm 上,Python Turtle Graphics 窗口只显示黑屏和滚动条。
I think the application called python.app is something wrong.我认为名为 python.app 的应用程序有问题。 That's why I updated python with brew and re-installed Pycharm, but nothing has changed.
这就是为什么我用 brew 更新了 python 并重新安装了 Pycharm,但没有任何改变。
Does anyone know how to fix this?有谁知道如何解决这一问题? Thank you.
谢谢你。
have you tried to install the latest version of python?你试过安装最新版本的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.
我尝试安装最新的 python 版本,它现在就像一个魅力。
将pycharm中的interprete pycharm解释器r改为3.9或3.10。
I don't think it has anything to do with the M1 processor.我认为这与 M1 处理器无关。 I have an M1 processor and had the same problem.
我有一个 M1 处理器并且有同样的问题。 My solution: Create a new project in Python.
我的解决方案:在 Python 中创建一个新项目。 Previously configured interpreter Select Python 3.10 (the latest installed version).
之前配置的解释器选择 Python 3.10(最新安装的版本)。 Click the button with the three dots ... Go to the directory of Python 3.10 (current version).
单击带有三个点的按钮... 进入 Python 3.10(当前版本)的目录。 IDLE.app -> Contents -> MacOS and -> Select Python.
IDLE.app -> 内容 -> MacOS 和 -> 选择 Python。 For me it looks like this:
对我来说,它看起来像这样:
/Applications/Python 3.10/IDLE.app/Contents/MacOS/Python /Applications/Python 3.10/IDLE.app/Contents/MacOS/Python
Then it works for me.然后它对我有用。
Updating the interpreter will help fix the issue as it did in my M1 Mac and without needing to make a new project.更新解释器将有助于解决问题,就像它在我的 M1 Mac 中所做的那样,而无需创建新项目。 However, there are a few extra steps needed to make sure it's compatible with your M1 chip.
但是,需要一些额外的步骤来确保它与您的 M1 芯片兼容。
Quick Steps:快速步骤:
/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" )/Applications/Python 3.10/IDLE.app/Contents/MacOS/Python
,然后按“确定”(重要提示:您的 Python 版本号可能不同,因此请更新将“Python 3.10”添加到“应用程序”中的 python 文件夹名称)The turtle screen should be now fixed!乌龟屏幕现在应该修复了! I hope this helped!
我希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.