You probably need to install it using something similar to the following:
For Ubuntu or other distros with Apt:
sudo apt-get install python3-tkFor Fedora:
sudo dnf install python3-tkinter
You can also mention a Python version number like this:
-
sudo apt-get install python3.7-tk -
sudo dnf install python3-tkinter-3.6.6-1.fc28.x86_64
Finally, import tkinter (for Python 3) or Tkinter (for Python 2), or choose at runtime based on the version number of the Python interpreter (for compatibility with both):
import sys
if sys.version_info[0] == 3:
import tkinter as tk
else:
import Tkinter as tk
Answer from d-coder on Stack OverflowYou probably need to install it using something similar to the following:
For Ubuntu or other distros with Apt:
sudo apt-get install python3-tkFor Fedora:
sudo dnf install python3-tkinter
You can also mention a Python version number like this:
-
sudo apt-get install python3.7-tk -
sudo dnf install python3-tkinter-3.6.6-1.fc28.x86_64
Finally, import tkinter (for Python 3) or Tkinter (for Python 2), or choose at runtime based on the version number of the Python interpreter (for compatibility with both):
import sys
if sys.version_info[0] == 3:
import tkinter as tk
else:
import Tkinter as tk
If you're using Python 3.9 on Mac, you can simply install tkinter using Homebrew:
brew install [email protected]
This fixed it for me.
As mentioned by others, you can also use the general command to install the latest version:
brew install python-tk
ModuleNotFoundError: No module named '_tkinter'
Bug: "ModuleNotFoundError: No module named '_tkinter" when importing PySimpleGUI
ModuleNotFoundError: No module named 'tkinter' in Ubuntu 20.04
python - Tkinter module not found on Ubuntu - Stack Overflow
Videos
i'm running into this error while trying to use tkinter. tried to sudo apt-get install python3-tk but still same problem.
Ubuntu version: VERSION="20.04.4 LTS (Focal Fossa)"
python: 3.12
If you are running python ver 3.x.x you should install tkinter for python3
sudo apt-get install python3-tk
That worked for me.
Note Tkinter has been renamed to tkinter in Python 3. (source:https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter). So in your codes, use import tkinter instead of import Tkinter. Also, in the codes, where there is Tkinter, use tkinter small letter instead.
What worked for me in Ubuntu was actually just:
Copysudo apt-get install python3-tk
For python 3.6:
Copysudo apt-get install python3.6-tk
I didn't read anywhere, I simply tried it, as onteria_'s method didn't seem to work for me.
The answer to your question is that Tkinter is renamed to tkinter in python3.
That is with lowercase t.
Hi everyone,
Im working in a project using Python and I ran into an issue regarding tkinter. The first time a execute the testing code:
from tkinter import *
from tkinter import ttk
root = Tk()
frm = ttk.Frame(root, padding=10)
frm.grid()
ttk.Label(frm, text="Hello World!").grid(column=0, row=0)
ttk.Button(frm, text="Quit", command=root.destroy).grid(column=1, row=0)
root.mainloop()
Gave me the following error --> ModuleNotFoundError: No module named 'tkinter'
Im using Fedora so I proceed installing tkinter using "sudo dnf install python3-tkinter" command. And when I run "python3 -m tkinter" from terminal it shows the pop-up window. But i keep ran in into the same error when I execute the code from VSC.
Anyone had an idea of how to solve this?
thank you all!
Hey guys
I am working in Visual Studio on a school assignment for my Computer Science class. It requires use of the turtle module. I am being told that it comes with python when you install it, however, when I try to use it, I am told that there is no module named ‘tkinter’. Could someone let me know what has to be done to fix this? Thanks