ImportError: No module named 'Tkinter'
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3
--
Chapters
00:00 Question
00:43 Accepted answer (Score 583)
01:32 Answer 2 (Score 92)
01:56 Answer 3 (Score 63)
02:20 Answer 4 (Score 47)
02:49 Thank you
--
Full question
https://stackoverflow.com/questions/2590...
Answer 1 links:
[documentation]: https://docs.python.org/2/library/tkinte...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #tkinter
#avk47
ACCEPTED ANSWER
Score 671
You probably need to install it using something similar to the following:
For Ubuntu or other distros with Apt:
sudo apt-get install python3-tkFor Fedora:
sudo dnf install python3-tkinter
You can also mention a Python version number like this:
-
sudo apt-get install python3.7-tk -
sudo dnf install python3-tkinter-3.6.6-1.fc28.x86_64
Finally, import tkinter (for Python 3) or Tkinter (for Python 2), or choose at runtime based on the version number of the Python interpreter (for compatibility with both):
import sys
if sys.version_info[0] == 3:
import tkinter as tk
else:
import Tkinter as tk
ANSWER 2
Score 94
As you are using Python 3, the module has been renamed to tkinter, as stated in the documentation:
Note Tkinter has been renamed to tkinter in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
ANSWER 3
Score 65
For Windows, make sure to check in the Python install the optional feature "tcl/tk and IDLE". Otherwise you get:
ModuleNotFoundError: No module named 'tkinter'
If Python is already installed without this optional feature, you need to amend the installation by launching again the Python installer and selecting Modify.
NB: you won't be able pip install tkinter, don't bother trying!
ANSWER 4
Score 48
To install the Tkinter on popular Linux distros:
Debian/Ubuntu:
sudo apt install python3-tk -y
Fedora:
sudo dnf install -y python3-tkinter
Arch:
sudo pacman -Syu tk --noconfirm
REHL/CentOS6/CentOS7:
sudo yum install -y python3-tkinter
OpenSUSE:
sudo zypper in -y python-tk