You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M1(Ventura13.4)运行Python turtle代码触发_tkinter.TclError报错

M1芯片Mac Ventura 13.4系统下Python Turtle画布异常及报错问题
  • 设备:搭载M1芯片的Mac电脑
  • 系统版本:Mac Ventura 13.4
  • 问题表现:运行任意简单Python turtle代码时,画布显示异常(截图:Turtle画布异常),同时触发报错信息如下:
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
Traceback (most recent call last):
  File "/Users/rohanomalley/Desktop/turppy/firstjourney.py", line 4, in <module>
    screen = turtle.Screen()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 3663, in Screen
    Turtle._screen = _Screen()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 3691, in __init__
    TurtleScreen.__init__(self, _Screen._canvas)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 996, in __init__
    self.clear()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 1028, in clear
    self.onclick(None, btn)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 1365, in onclick
    self._onscreenclick(fun, btn, add)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 669, in _onscreenclick
    self.cv.unbind("<Button-%s>" % num)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/turtle.py", line 422, in unbind
    self._canvas.unbind(*args, **kwargs)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1397, in unbind
    self.tk.call('bind', self._w, sequence, '')
_tkinter.TclError: can't invoke "bind" command:  application has been destroyed

测试代码

import turtle

t = turtle.Turtle()

t.pencolor("red")

t.circle(100)

turtle.mainloop()

已尝试操作

曾尝试过同类问题的解决方案,但未解决当前问题。

内容的提问来源于stack exchange,提问作者Rohan Omalley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 06:53:25