31

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?

Tom Boy
  • 599
  • 2
  • 8
  • 14

6 Answers6

47

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.

McClamrock
  • 857
  • 1
  • 8
  • 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
23

tkinter.TclVersion and tkinter.TkVersion described in other answers provide the major and minor Tcl/Tk versions but not the patch number.

On the other hand, the info patchlevel Tcl command returns the version in the major.minor.patch format.

import tkinter

tcl = tkinter.Tcl()
print(tcl.call("info", "patchlevel"))

# Output:
# 8.6.10

The following should be preferred to call the command from a Tkinter app, which already has an associated Tcl interpreter:

import tkinter

root = tkinter.Tk()
...
print(root.tk.call("info", "patchlevel"))

# Output:
# 8.6.10
Demian Wolf
  • 1,698
  • 2
  • 14
  • 34
7

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.

Sandun
  • 395
  • 2
  • 10
  • 25
4

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):

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
3

Run Tkinter.TclVersion or Tkinter.TkVersion and if both are not working, try Tkinter.__version__

Xposedbones
  • 597
  • 4
  • 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
  • 2
    This looks like Python 2 code. Also, my copy of `tkinter` doesn't have a `__version__` attribute, which is why I'm here. – Ilya Jun 17 '22 at 22:25
1

In the terminal try as follows:

python -m tkinter or python3 -m tkinter