默认情况下macos下的brew和pyenv安装的python是不带turtle模块的,
如果你要使用的话,可以这样做:
- 去python官网下载macos的python安装包。它已经包含了Tk模块。
Python Releases for Mac OS X | Python.org
官网有个说明页面:
IDLE and tkinter with Tcl/Tk on macOS | Python.org
If you are using a Python from any current python.org Python installer for macOS (3.8.0+, 3.7.2+, 3.6.8, or 2.7.16+), no further action is needed to use IDLE or tkinter. A built-in version of Tcl/Tk 8.6 will be used.
- 安装以后,需要将pyenv的环境变量从user profile中取消,然后重新source user profile。
- 此时就可以正常的使用turtle模块了。