1、确定Tkinter没有安装: zhancang@debian:~$ python Python 2.4.4 (#2, Apr 5 2007, 20:11:18) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 41, in ? raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk package >>>
2、安装Tkinter: zhancang@debian:~$ su - Password: debian:~# aptitude install python-tk Reading package lists... Done Building dependency tree... Done Reading extended state information Initializing package states... Done Writing extended state information... Done Reading task descriptions... Done Building tag database... Done The following NEW packages will be automatically installed: blt tk8.4 The following NEW packages will be installed: blt python-tk tk8.4 0 packages upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 2565kB of archives. After unpacking 6676kB will be used. Do you want to continue? [Y/n/?] y Writing extended state information... Done Get:1 etch/main tk8.4 8.4.12-1etch2 [978kB] Get:2 etch/main blt 2.4z-4 [1528kB] Get:3 etch/main python-tk 2.4.4-1 [59.4kB] Fetched 2565kB in 2s (918kB/s) Selecting previously deselected package tk8.4. (Reading database ... 72536 files and directories currently installed.) Unpacking tk8.4 (from .../tk8.4_8.4.12-1etch2_i386.deb) ... Selecting previously deselected package blt. Unpacking blt (from .../archives/blt_2.4z-4_i386.deb) ... Selecting previously deselected package python-tk. Unpacking python-tk (from .../python-tk_2.4.4-1_i386.deb) ... Setting up tk8.4 (8.4.12-1etch2) ...
Setting up blt (2.4z-4) ...
Setting up python-tk (2.4.4-1) ... debian:~#
3、安装成功: zhancang@debian:~$ python Python 2.4.4 (#2, Apr 5 2007, 20:11:18) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter >>>