After a day of headache, this worked for me:
$ brew install python-tk
Answer from subtleseeker on Stack OverflowAfter a day of headache, this worked for me:
$ brew install python-tk
I've had the same issue:
ModuleNotFoundError: No module named 'tkinter'
After quite a while I finally realized that I needed to install the python-tk package. On Linux all I needed to do was sudo apt-get install python3-tk.
python - Updating tcl/tk version of Homebrew python3 on macOS - Stack Overflow
How do I run the version of tkinter I brew installed instead of the system version?
How to update tcl-tk? - Apple Community
Tkinter for python 3.10 broken on MacOS?
Python versions above 3.6 are messed up for Mac afaik, at least you need some fix with the new Mac chip, you have to have the package run it via Rosetta or something? (I can't quite remember it's been months since I set up 3.9) so it could also be that
Newer versions of python always a bit less stable, so maybe try 3.9 or something
More on reddit.comAfter many more failures, I concluded that the easiest way to make this work is to completely forget about Homebrew, uninstall its python packages.
Then install the latest ActiveTcl and then the python.org version instead. The python.org version will work on top of the latest "System" Tcl/TK, which will be refreshed after installing the ActiveTcl. Unfortunately, Homebrew ignores it.
The current 3.7.2 from python.org is compiled with Tcl/TK 8.6.8:
$ python3
Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
>>> print(tk.Tcl().eval('info patchlevel'))
8.6.8
After updating it, several bugs like checkbuttons showing wrong checkmarks on a menu disappeared.
This post provides a neat way:
https://stackoverflow.com/a/60469203/10606936
NOT NEEDED to use actviveTk or python.org python installation.
Keypoint is provide the correct ENV for installtion.
On MacOS 12.5 I have updated to the latest version of Python and pip and I just brew installed tkinter. When I do "python3 -m tkinter", I get the message: DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. - and the window that launches is buggy.
It seems like the command above is not running the version of tkinter I just installed with brew.
Why is that and how do I get rid of this deprecated system version?
Or in general what is the real issue here?
Thanks very much
Hello, I read on the internet that there are some problems with Tkinter on laster MacOS updates like buttons invisible, UI bugs...Since I had some problems too recently, do you know anything about this situation?
EDIT : Solved! There is a package studied from Mac that extends tkinter and solves many problems. Take a look at my GitHub’s issue, there are all steps to solve the problem and install the package( tkmacosx) :
https://github.com/Saadmairaj/tkmacosx/issues/33
Python versions above 3.6 are messed up for Mac afaik, at least you need some fix with the new Mac chip, you have to have the package run it via Rosetta or something? (I can't quite remember it's been months since I set up 3.9) so it could also be that
Newer versions of python always a bit less stable, so maybe try 3.9 or something
3.10 is fresh off the press. I'd stick with 3.9 for a couple of months more unless you for some reason need 3.10.
For tkinter specifically you're better off posting on their git repo.
Hello everyone,
I'm trying to tackle school coursework requiring me to use the Tkinter library. Initially, anything I would attempt to display would result in a black screen. After consulting with ChatGPT, and reinstalling python and tcl-tk via homebrew I now receive this error :
~ % python3 -m tkinter
import _tkinter # If this fails your Python may not be configured for Tk
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'
These are the versions of python I'm using :
~ % which python3
/opt/homebrew/bin/python3
~ % python3 --version
Python 3.13.0
brew install tcl-tk
Warning: tcl-tk 9.0.0_1 is already installed and up-to-date.
MAC OS : 15.0.1 (24A348)
If anyone has any suggestions on how I could solve this error please let me know.
» pip install tkmacosx