我使用Ubuntu 11.10,它预装了Python 2.7.3。如何让tkinter使用Ubuntu的默认Python 2.7安装?
我安装了python3封装,python3-tk的包,通过apt-get安装,和他们一起工作“开箱即用”。
然而,尽管我已经安装了Python-tk的包,我无法弄清楚如何让Python2.7看到它。当我尝试导入时,出现以下错误消息。
import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
编辑:我也跑了以下基于Python-tk package not recognized in Python 2.7.3,并得到了:
$ file /usr/lib/libtk8.5.so.0
/usr/lib/libtk8.5.so.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
$ uname -a
Linux bugbot 3.0.0-23-generic-pae #39-Ubuntu SMP Thu Jul 19 19:39:19 UTC 2012 i686 i686 i386 GNU/Linux
我知道在Python 3里,Tkinter的模块被小写( “Tkinter的”)。所以你可以尝试“导入tkinter”。然后,这个人(http://ubuntuforums.org/showthread.php?t=1699456)似乎也有类似的问题,但它看起来比使用错误的名称更深层。 – seaotternerd 2012-08-01 03:47:02
我试过了小写字母和大写......都没有工作,只有大写的给我提供了更具体的错误信息。 – 2012-08-01 03:58:12