Installing tkinter on ubuntu 14.04

Mayank Jain picture Mayank Jain · Nov 2, 2014 · Viewed 157.6k times · Source

I want to run python code on Ubuntu 14.04, but when I execute it, it gives me the following error message

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from tkinter import *
ImportError: No module named tkinter

Answer

the_dude picture the_dude · Nov 2, 2014

Try writing the following in the terminal:

sudo apt-get install python-tk

Don't forget to actually import Tkinter module at the beginning of your program:

import Tkinter