Tkinter on mac shows up as a black screen

Viewed 80
2 Answers

I have the same issue on an M1 Pro. Works just fine on the intel Mac but not the M1. I have a further issue on the file dialog in which the file type does not appear in the M1 but works perfectly on the Intel Mac. I am not convinced that the hardware is the problem but more that it is the port of Tkinter to the platform.

After much digging, I've found a solution (with some caveats) - you'll need both homebrew and pyenv installed for this to work. The idea is to replace your old deprecated tkinter installation with an up-to-date one that actually works*

Note that this will wipe out any packages you’ve installed with pip - back those up first!

Run the following commands

brew uninstall tcl-tk uninstall the old tk if you have it

pyenv uninstall 3.10.5 ...or whatever your current global Python version is

brew install tcl-tk grab a fresh install of tk

pyenv install 3.10.5 grab a fresh install of Python 3.10.5

pyenv global 3.10.5 set your global Python version

You need to install tk via homebrew before installing Python with pyenv because pyenv will automatically try to use whatever tk package it can find when it installs Python.

Final Thoughts

If you don't already have homebrew installed, here are good instructions

If you don't have pyenv, just run brew install pyenv

You’ll probably need to select your preferred Python interpreter in VSCode again

*This worked for me - YMMV

Related