Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter module not found on Ubuntu

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)  [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter >>>  

on the other hand...

Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)  [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Tkinter  

I checked synaptic, Tkinter is installed. Then I found this--

If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.

I am guessing that tkinter is still associated with the old python in my pc. How do I change that so python3 can use tkinter?

like image 362
Jim Syyap Avatar asked May 21 '11 20:05

Jim Syyap


People also ask

Why tkinter is not working in Ubuntu?

You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.

How do I get tkinter in Ubuntu?

Instructions for Ubuntu Install Tkinter: apt-get install python-tk (restart after) Install setuptools: sudo apt-get install python-setuptools. Install suds: sudo easy_install suds. Install matplotlib: sudo apt-get install python-matplotlib.

Does tkinter work on Ubuntu?

Wikipedia says: "Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit1 and is Python's de facto standard GUI,2 and is included with the standard Windows and Mac OS X install of Python." - Not good, that it isn't included in Ubuntu as well.

Why tkinter is not working in Python?

The easiest way to fix this problem is by upgrading your python to use python 3. If upgrading python is not an option, you only need to rename your imports to use Tkinter (uppercase) instead of tkinter (lowercase). Output: As a result, this window proves that your python installation includes the Tkinter module.


2 Answers

What worked for me in Ubuntu was actually just:

sudo apt-get install python3-tk 

For python 3.6:

sudo apt-get install python3.6-tk 

I didn't read anywhere, I simply tried it, as onteria_'s method didn't seem to work for me.

like image 172
Pinna_be Avatar answered Oct 05 '22 10:10

Pinna_be


The answer to your question is that Tkinter is renamed to tkinter in python3

that is with lowercase t

like image 30
Nils Nyman Avatar answered Oct 05 '22 09:10

Nils Nyman