Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDLE can't import Tkinter. Your Python may not be configured for Tk

I am running Ubuntu 10.10, and I installed Python 3.2 today. The system is already running Python 2.6.

I typed idle3.2 in the terminal and it gave me:

IDLE can't import Tkinter. Your Python may not be configured for Tk.

So I searched on Stack Overflow (and in some other places) for a solution, I installed python-tk, I rechecked that I have tclsh on the system, but I still can't manage to open idle3.2.

Any input would be appreciated.

like image 916
breeder Avatar asked Jun 12 '11 08:06

breeder


People also ask

What is import Tkinter as TK in Python?

Using import tkinter as tk It comes with all the modules defined in tkinter. However, to save the major typing efforts, we import the tkinter library with some acronym further that can be used to create an instance of widgets. Thus, the application structures become more aesthetical by using the import tkinter as tk.

What is Tk () in Tkinter Python?

Tkinter is a Python package which comes with many functions and methods that can be used to create an application. In order to create a tkinter application, we generally create an instance of tkinter frame, i.e., Tk(). It helps to display the root window and manages all the other components of the tkinter application.

Is Tkinter the same as TK?

Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de facto standard GUI. Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python. The name Tkinter comes from Tk interface.


1 Answers

On OSX, this can be resolved with macports by installing the python tkinter package for your python version. In my case, with python 2.7, I ran on the terminal:

sudo port install py27-tkinter

change the "27" to your python version number.

like image 180
beibei2 Avatar answered Oct 12 '22 00:10

beibei2