아무거나/진짜 아무거나

pyenv로 python 사용 시에 tkinter black screen 에러 혹은 Deprecation warning 해결하기

톰거봉 2022. 10. 11. 16:37

python에서 tkinter 사용 시에 black screen이 뜨거나 혹은 Deprecation warning 이 나는 경우가 있다 (특히 맥에서)

이럴 땐 일단 system 에 tcl-tk를 다시 깔아준다

brew reinstall tcl-tk

하지만 이거만으로는 해결이 안됨

 

왜냐하면 pyenv는 python을 깔때 build를 하는데

그 때 당시에 쓰이게 될 tcl-tk가 정해지는 거라서 새로 설치한게 반영이 안되기 때문이다

 

Python 3.10 이상의 버전을 새로 까는 걸 추천한다

pyenv install 3.10.0
$ pyenv install 3.10.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.10.0...
patching file aclocal.m4
patching file configure
Hunk #5 succeeded at 10537 (offset -15 lines).
patching file Misc/NEWS.d/next/Build/2021-10-11-16-27-38.bpo-45405.iSfdW5.rst
patching file configure
patching file configure.ac
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.10.0 to /Users/gabin/.pyenv/versions/3.10.0

python-build: tcl-tk 가 보이는지,, 요 때 바인딩 된다고 생각하면 된다

새로 설치된 python 3.10.0 으로 tkinter 실행하면 해결 완료 🤓

 

Tkinter를 깔았는데 뭘 만들지 모르는 사람의 첫 작품

반응형