1
1

More than 5 years have passed since last update.

Tkinterインポートエラーの対処法

Last updated at Posted at 2017-12-03

Pythonの標準ライブラリであるTkinterがインポートできずに困ったので、備忘録として残しておきます。

状態

実行すると下記のエラーがでました。

>python ./gui1.py
Traceback (most recent call last):
File "./gui1.py", line 1, in
from Tkinter import *
ImportError: No module named 'Tkinter'

Tkinterがインポートされてないよとでます。

直し方

大文字と小文字を区別するらしく、下記で修正できました。
×:from Tkinter import *
〇:from tkinter import *

大文字と小文字を区別するのはpython3かららしく、
python2のサイトを参考にしてると引っかかります。

参考:
答えを知りたい

その他

初めはどっかからインストールしなければいけないのかと思って探してしまいました。
また、標準のpythonではなく、ダウンロードしたpythonで実行するとだめな場合があるようです。
自分は初めに下記を試してみましたが、事象が異なり、上記の方法で修正できました。
参考:
stack overflow

1
1
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
1
1