2
0

ModuleNotFoundError: No module named '_tkinter' の時の対処法

Posted at

macOSを使っている著者が、tkinterを使って遊ぼうと思った時に、タイトルのエラーにでくわしました。
めっちゃ簡潔に、このエラーを解決した手順を記しておきます。

$ brew install tcl-tk
(中略)

でインストールしたtinkerについて、以下のエラーが出ました。

$ python3
Python 3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import tkinter
(中略)
ModuleNotFoundError: No module named '_tkinter'

調べたところ、よくあるバージョンの食い違いエラーだったみたいです。
具体的にはPythonとtkinterとのバージョンの食い違いです。

$ python3 --version
Python 3.12.2

このPythonに合わせたtkinterをインストールします。

$ brew install python-tk@3.12.2

これで解決しました。

あんまり意義のない記事かと思いますが、質より量かと思って残しておきます。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0