When I first learn Python, I wanted to use tkinter package. I write a Python file tkinter.py . I write “import tkinter” in it. But I cannot use the functions in tkinter. So which file does it import? The standard library or this tkinter.py ?
Sounds like you’re importing your own file–in general it is tricky to name your file the same thing as a package you’d like to use. You can check what file a given module is getting imported from by printing out the __file__
attribute, i.e. print(tkinter.__file__)
1 Like
Thank you very much!
When you run myfile.py, Python normally first looks in the myfile.py directory to find files to import.