3

I'm trying to run app with Mac M1

Errors are:

bash-3.2$ brew install tkinter
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 8 formulae.

Warning: No available formula with the name "tkinter".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

bash-3.2$ pip install tkinter
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none)
ERROR: No matching distribution found for tkinter
5
  • 1
    Do you already have python installed? Tkinter is usually part of a standard python distribution. Unfortunately I don't have an m1 mac to try it out. Commented Feb 14, 2022 at 16:26
  • Yes. Frustrating because I want to play.
    – elksie5000
    Commented Feb 14, 2022 at 21:33
  • 1
    You have python installed? What happens when you try to import tkinter? Commented Feb 14, 2022 at 21:35
  • 1
    ModuleNotFoundError Traceback (most recent call last) <ipython-input-4-29b37e014535> in <module> ----> 1 import tkinter /usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py in <module> 35 import types 36 ---> 37 import _tkinter # If this fails your Python may not be configured for Tk 38 TclError = _tkinter.TclError 39 from tkinter.constants import * ModuleNotFoundError: No module named '_tkinter'
    – elksie5000
    Commented Feb 14, 2022 at 21:39
  • 1
    Does this solve your problem? stackoverflow.com/a/68554984/7432 Commented Feb 14, 2022 at 21:42

1 Answer 1

5

Apparently on MacOS' python, tkinter is not a built-in and can't be installed with pip. In order to install it you need either MacPorts or Homebrew. Since the newest tkinter module for python 3.11 is still a little bit buggy, I would recommend you to install the tkinter module for python 3.9 which is more stable by running either of these commands:

  • With MacPorts
sudo port install py39-tkinter
  • With Homebrew
brew install [email protected]

but if you insist on installing the latest version, go ahead with either of these:

sudo port install py311-tkinter
brew install python-tk

After installing, you should instantly be able to import tkinter.

Not the answer you're looking for? Browse other questions tagged or ask your own question.