I’m on Linux Ubuntu 22.10.
So I installed Tkinter using this command:
<code>python3 -m pip install tk
</code>
<code>python3 -m pip install tk
</code>
python3 -m pip install tk
and the output was fine:
<code>Defaulting to user installation because normal site-packages is not writeable
Collecting tk
Using cached tk-0.1.0-py3-none-any.whl.metadata (693 bytes)
Using cached tk-0.1.0-py3-none-any.whl (3.9 kB)
Installing collected packages: tk
Successfully installed tk-0.1.0
</code>
<code>Defaulting to user installation because normal site-packages is not writeable
Collecting tk
Using cached tk-0.1.0-py3-none-any.whl.metadata (693 bytes)
Using cached tk-0.1.0-py3-none-any.whl (3.9 kB)
Installing collected packages: tk
Successfully installed tk-0.1.0
</code>
Defaulting to user installation because normal site-packages is not writeable
Collecting tk
Using cached tk-0.1.0-py3-none-any.whl.metadata (693 bytes)
Using cached tk-0.1.0-py3-none-any.whl (3.9 kB)
Installing collected packages: tk
Successfully installed tk-0.1.0
so I tried to use the module; I wrote a basic file to display a window:
<code>import tk
window = tk.Tk()
window.mainloop()
</code>
<code>import tk
window = tk.Tk()
window.mainloop()
</code>
import tk
window = tk.Tk()
window.mainloop()
and then it threw me this error: AttributeError: module 'tk' has no attribute 'Tk'
.
Okay, I’ll just check the source file. I went to Home/.local/lib/Python3.10/site-packages/tk/__init__.py
Hey, waitaminit. It’s empty? 0 bytes.
I’m so confused. can someone explain?
New contributor
Dw8ke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.