Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing tkinter on ubuntu 14.04

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 
like image 235
Mayank Jain Avatar asked Nov 02 '14 17:11

Mayank Jain


People also ask

How do I install Tkinter on 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.

Is Tkinter available for Linux?

Tkinter can be installed in other Linux based distributions from the package manager. You can also install Tkinter packages in Linux by following installation instructions available here.

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.

Can I pip install Tkinter?

Tkinter can be installed using pip. The following command is run in the command prompt to install Tkinter. This command will start downloading and installing packages related to the Tkinter library.


1 Answers

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 
like image 107
the_dude Avatar answered Oct 02 '22 17:10

the_dude