[SOLVED] Python Turtle Shows Blank Screen
Hi Guys,
Recently, my python turtle shows blank screen when running, but before that, the shell shows below warning message. (by the way I use macOS Monterey 12.4, and python 3.10.4, pyenv 2.3.0)
"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."
from above warning, we know that tk version is older than the tcl-tk which python 3.10.x use, and I guess this problem cause the python turtle shows blank screen like this 👇🏻
SOLUTION
Since I use pyenv to manage my python installations, so here is what I did:
1. Uninstall current python in pyenv
$ pyenv uninstall 3.10.4
2. Update / Install tcl-tk using brew
$ brew install tcl-tk
$ brew info tcl-tk
tcl-tk: stable 8.6.12 (bottled) [keg-only]
3. Install python using pyenv again with env variables tcl-tk like these 👇🏻
$ env \
PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \
CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
CFLAGS="-I$(brew --prefix tcl-tk)/include" \
PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \
pyenv install 3.10.4
4. Done
If you like this article, please consider to subscribe my youtube channel, I will create videos about python and AI 🥰
この記事が気に入ったらサポートをしてみませんか?