-1

I am working on Python v2.x windows os. I notice tcl (including TKinter) IS installed while I am having Python installed.

But when I verify it by typing 'import tkinter' on Python IDLE, there is error: "ImportError: No module named tkinter"

Could anyone give me some advice? Thanks.

Amber.G
  • 1,343
  • 5
  • 12
  • 16

2 Answers2

1

In Python2,

import Tkinter

In Python3

import tkinter
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
1

Python 2.x use Tkinter - see upper T.

In Python 3.x name was changed to tkinter

To work with both Pythons you can use

try:
    import Tkinter as tk
except ImportError:
    import tkinter as tk


root = tk.Tk()
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
furas
  • 134,197
  • 12
  • 106
  • 148