linux – Install tkinter for Python
linux – Install tkinter for Python
It is not very easy to install Tkinter locally to use with system-provided Python. You may build it from sources, but this is usually not the best idea with a binary package-based distro youre apparently running.
Its safer to apt-get install python-tk
on your machine(s).
(Works on Debian-derived distributions like for Ubuntu; refer to your package manager and package list on other distributions.)
Actually, you just need to use the following to install the tkinter for python3:
sudo apt-get install python3-tk
In addition, for Fedora users, use the following command:
sudo dnf install python3-tkinter
linux – Install tkinter for Python
If, like me, you dont have root privileges on your network because of your wonderful friends in I.S., and you are working in a local install you may have some problems with the above approaches.
I spent ages on Google – but in the end, its easy.
Download the tcl and tk from http://www.tcl.tk/software/tcltk/download.html and install them locally too.
To install locally on Linux (I did it to my home directory), extract the .tar.gz files for tcl and tk. Then open up the readme files inside the ./unix directory. I ran
cd ~/tcl8.5.11/unix
./configure --prefix=/home/cnel711 --exec-prefix=/home/cnel711
make
make install
cd ~/tk8.5.11/unix
./configure --prefix=/home/cnel711 --exec-prefix=/home/cnel711 --with-tcl=/home/cnel711/tcl8.5.11/unix
make
make install
It may seem a pain, but the files are tiny and installation is very fast.
Then re-run python setup.py build
and python setup.py install
in your python installation directory – and it should work. It worked for me – and I can now import Tkinter etc to my hearts content – yipidy-yay. An entire afternoon spent on this – hope this note saves others from the pain.