简体   繁体   中英

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.

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.

On Ubuntu:

sudo apt-get install idle

Choose one from

  • idle
  • idle3
  • idle-python2.6
  • idle-python2.7
  • idle-python3.1
  • idle-python3.2

for your python version.

The problem is caused by the version between python and idle not matching. U can check your python version by typing: python Then sudo aptget install the right idle version same with your python version

I ran into the same error message when installing python3.4 on Fedora 20. The problem was that tk-devel was not installed during the python configure/make. The explicit steps to do this correctly are

download and extract python3.4 from python.org https://www.python.org/downloads/

Find and install the right tkinter and tk-devel:

yum search tkinter

yum install python3-tkinter-3.3.2-17.fc20.x86_64

yum search tk-devel

yum install tk-devel.x86_64

AFTER these are onboard, cd into the python3.4 package directory and run the configure; make, make install process.

I spent too much time resolving this issue. Hopefully this post will help may others to a quick resolution.

PS stackoverflow is awesome. If google brought you to this article, spend some time and surf around the site.

If you installed python-tk and the system is running python 2.6 then it is most likely that you installed Tkinter for python 2.6. Try installing python3-tk.

you need to install tk or tk-dev packages for ubuntu.

Type "idle-python2.6" in the terminal..it worked for me

On my arch linux system I had the same problem easily solved by typing

yaourt tkinter

and installing the first package community/python-pmw 2.0.1-2 [installed]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM