Coder Perfect

Install Python’s tkinter package.


I’m attempting to get Tkinter to work. However, I receive the following error: Tkinter is not installed:

ImportError: No module named _tkinter, please install the python-tk package

I could probably install it with synaptic manager (can I? ), but I’d have to do so on each machine where I program. Is it possible to include the Tkinter library in my workspace and use it from there?

Asked by Karan

Solution #1

Tkinter is difficult to install locally for use with system-provided Python. You can build it from sources, but with a binary package-based distro like the one you’re using, this is usually not a good idea.

It’s safer to install python-tk with apt-get on your machine (s). (On other distributions, consult your package management and package list; on Debian-derived distributions, consult your package manager and package list.)

Answered by 9000

Solution #2

Actually, to install tkinter for Python 3, you only need to do the following:

sudo apt-get install python3-tk

Use the following command if you’re using Fedora:

sudo dnf install python3-tkinter

Answered by Neil

Solution #3

If, like me, you don’t have root access on your network due to your lovely friends in I.S., and you’re working in a local setup, the preceding ways may cause some issues.

I spent a long time on Google, but it’s actually quite simple.

Install tcl and tk locally by downloading them from

Extract the.tar.gz files for tcl and tk to install locally on Linux (I did it to my home directory). Then, under the./unix directory, open the readme files. I took off running.

cd ~/tcl8.5.11/unix
./configure --prefix=/home/cnel711 --exec-prefix=/home/cnel711
make install

cd ~/tk8.5.11/unix
./configure --prefix=/home/cnel711 --exec-prefix=/home/cnel711 --with-tcl=/home/cnel711/tcl8.5.11/unix
make install

It may appear to be a hassle, but the files are little and installation is quick.

Then, in your python installation directory, run python build and python install again, and it should work. It worked for me, and now I can import Tkinter and other programs to my heart’s desire – yipidy-yay. An entire afternoon spent on this – hope this note saves others from the pain.

Answered by Simon

Solution #4

If you’re using Python 3, it’s possible that you’re typing Tkinter instead of tkinter.

Answered by user1497423

Solution #5

It goes something like this for Arch Linux users:

sudo pacman -S tk

Answered by yermama

Post is based on