3

When I try the following code :

import Tkinter
Tkinter._test()

I get the following error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 3835, in _test
    root = Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1818, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories: 
/usr/local/lib/tcl8.6/tk8.6 /usr/local/lib/tk8.6 /usr/lib/tk8.6 /usr/lib/tk8.6 /lib/tk8.6 /usr/library



This probably means that tk wasn't installed properly.

I tried to reinstall Tkinter, but it still give the same error.

Can I have help please ?

2 Answers2

0

Install python-tk and I think you will solve your problems.

sudo apt-get install python-tk
ubfan1
  • 19,049
0

Tkinter has a different name in Python 2 and 3.

  • Python 2: import Tkinter
  • Python 3: import tkinter

Unless you have a very good reason, use Python 3. Make sure tkinter is installed by running sudo apt-get install python3-tk and use the python3 command in the terminal.

Timo
  • 4,700