auf meinem Rechner (Ubuntu 10.04) sind zwei Python-Versionen installiert, 2.6.5 und 3.1.2, wobei ich nur mit der 3er-Version programmiere.
Gestern wollte ich mich (mit Version 3) an Tkinter heranwagen, bekam vom Interpreter aber folgende Fehlermeldung ausgeworfen:
Code: Alles auswählen
Python 3.1.2 (r312:79147, Sep 27 2010, 09:45:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "/usr/lib/python3.1/tkinter/__init__.py", line 40, in <module>
import _tkinter
ImportError: No module named _tkinter
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.1/tkinter/__init__.py", line 42, in <module>
raise ImportError(str(msg) + ', please install the python-tk package')
ImportError: No module named _tkinter, please install the python-tk package
Dann probierte ich es mal mit der 2er-Version, was sofort tadellos funktionierte und mir ein Fenster hinzauberte:
Code: Alles auswählen
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Tkinter
<module 'Tkinter' from '/usr/lib/python2.6/lib-tk/Tkinter.pyc'>
>>> frame = Tkinter.Tk()
>>>
Wie bekomme ich Tkinter unter Python 3.x zum Laufen? Woher nehme ich das Modul _tkinter? Ist das ein Problem des Ubuntu-Pakets? Hatte so einen Fall neulich mit Ren'Py schon mal, da war das Ubuntu-Paket schuld…