I am asking as lately while doing python GUI programing I installed tkinter by doing

apt-get install python3-tk

everything went well and when I opened python3 console while I was in the following directory


But I moved to an other folder called "tkinter" in "python-gui" folder and tried to compile the following code

 import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        tk.Frame.__init__(self, master)

    def createWidgets(self):
        self.hi_there = tk.Button(self)
        self.hi_there["text"] = "Hello World\n(click me)"
        self.hi_there["command"] = self.say_hi

        self.QUIT = tk.Button(self, text="QUIT", fg="red",

    def say_hi(self):
        print("hi there, everyone!")

root = tk.Tk()
app = Application(master=root)

I did

python3 tkinter.py 

and surprisingly I get this error

Traceback (most recent call last):
  File "tkinter.py", line 1, in <module>
    import tkinter as tk
  File "/root/python_gui/tkinter/tkinter.py", line 3, in <module>
    class Application(tk.Frame):
AttributeError: 'module' object has no attribute 'Frame'

so I entered python3 console from that path and tried importing tkinter inside the console but again got the same error, but when I try compiling the same code under "python-gui" folder directly it imports and compiles properly, and also when I am in "~/python-gui/tkinter/" folder I tried


tkinter didnt import again but I come out and try again it does, why isn't python module not working in the "/tkinter/" folder ? and how do I fix this ?

Thank you.

os info : Linux root 4.0.0-kali1-amd64 #1 SMP Debian 4.0.4-1+kali2 (2015-06-03) x86_64 GNU/Linux

python : python 3.4.2

closed as off-topic by Jeff Schaller, slm Jun 26 '16 at 14:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, slm
If this question can be reworded to fit the rules in the help center, please edit the question.


Well my bad, I named the program file tkinter.py while calling module tkinter, modules should usually work irrespective of the folder, just renaming the file name did the job. You can name your file name similar to a modules name, as there will be a file for it already.

Not the answer you're looking for? Browse other questions tagged or ask your own question.