Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install tkinter for Python

I am trying to import Tkinter. However, I get an error stating that Tkinter has not been installed:

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

I could probably install it using synaptic manager (can I?), however, I would have to install it on every machine I program on. Would it be possible to add the Tkinter library into my workspace and reference it from there?

like image 268
Karan Avatar asked Jan 24 '11 15:01

Karan


2 Answers

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 you're apparently running.

It's 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.)

like image 55
9000 Avatar answered Oct 14 '22 19:10

9000


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 
like image 37
Neil Avatar answered Oct 14 '22 19:10

Neil