My Idle is throwing errors that and says tkinter
can\'t be imported.
Is there a simple way to install tkinter
via pip
or
The Tkinter library is built-in with every Python installation. And since you are on Windows, I believe you installed Python through the binaries on their website?
If so, Then most probably you are typing the command wrong. It should be:
import Tkinter as tk
Note the capital T at the beginning of Tkinter.
For Python 3,
import tkinter as tk
Inside cmd
, run command pip install tk
and Tkinter should install.
if your using python 3.4.1 just write this line from tkinter import *
this will put everything in the module into the default namespace of your program. in fact instead of referring to say a button like tkinter.Button
you just type Button
When installing make sure that under Tcl/Tk
you select Will be installed on hard drive
. If it is installing with a cross at the left then Tkinter will not be installed.
The same goes for Python 3:
Had the same problem in Linux. This solved it. (I'm on Debian 9 derived Bunsen Helium)
$ sudo apt-get install python3-tk
I'm posting as the top answer requotes the documentation which I didn't find useful.
tkinter comes packaged with python install on windows IFF you select it during the install window.
The solution is to repair the installation (via uninstall GUI is fine), and select to install tk this time. You may need to point at or redownload the binary in this process. Downloading directly from activestate did not work for me.
This is a common problem people have on windows as it's easy to not want to install TCL/TK if you don't know what it is, but Matplotlib etc require it.