Search code examples
pythontkintertk-toolkit

AttributeError: module 'tk' has no attribute 'Tk'


It seem like pip install tkinter has been renamed to pip install tk. But when I try to run it, this happens:

AttributeError: module 'tk' has no attribute 'Tk'

This is my Code:

import tk 
from tk import *

base = Tk()
## base = tk.Tk() does not work as well

Also, there is no file in my directory named tkinter or tk and on Tkinter page has no mention about the change. Is anyone facing the same issue?

Any help appreciated. Thanks in advance.


Solution

  • You are confusing two different things tkinter built-in module and tk external module, second is TensorKit is a deep learning helper between Python and C++. You should do

    from tkinter import *
    base = Tk()
    

    Consult linked docs if you want to know more