Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?
6 Answers
In Python 3, it's tkinter with a small t, and you need to import it. Thus:
>>> import tkinter
>>> tkinter.TkVersion
8.6
If you didn't import it, you'd get the error you mentioned.
- 797
- 7
- 12
-
When I import it I get the error saying 'ImportError: No module named '_tkiner'', I have done sudo apt-get install python3-tk and sudo apt-get install tk-dev. They both say there are in the newest version but my error still shows up when I try import tkinter. – Tom Boy Mar 14 '16 at 23:38
Previous answers describe tkinter.TclVersion and tkinter.TkVersion that provide the major and minor Tcl/Tk versions but not the patch number.
To get the full version in the major.minor.patch format, you could use the info patchlevel Tcl command.
For example:
import tkinter
tcl = tkinter.Tcl()
print(tcl.call("info", "patchlevel"))
# Output:
# 8.6.10
To do the same from a Tkinter app, which already has an associated Tcl interpreter, you could run this instead:
import tkinter
root = tkinter.Tk()
...
print(root.tk.call("info", "patchlevel"))
# Output:
# 8.6.10
- 1,488
- 2
- 11
- 28
Type this command on the Terminal and run it.
python -m tkinter
A small window will appear with the heading tk and two buttons: Click Me! and QUIT. There will be a text that goes like This is Tcl/Tk version ___. The version number will be displayed in the place of the underscores.
- 355
- 2
- 8
- 19
Run Tkinter.TclVersion or Tkinter.TkVersion and if both are not working, try Tkinter.__version__
- 587
- 3
- 7
-
They all give back an error saying NameError: name 'Tkinter' is not defined. I even tried with a smaller case "t" and getting the same error. – Tom Boy Mar 14 '16 at 22:58
You cal so invoke TclVersion:
>>> import tkinter
>>> tkinter.TclVersion
8.6
Tested for Python 3.6.5 and Python 3.5.2 (Ubuntu 16.04.4):
- 17,880
- 38
- 105
- 123