So, I’m trying to use a project, that uses tkinter on my Raspberry Pi but I have an issue. I needed an updated version of Python, so I updated it to 3.7.4, however, when I try to
import tkinter, it gives me the error message
ModuleNotFoundError: No module named '_tkinter'. Tkinter also gives the message
If this fails, your Python may not be configured for Tk. Other modules import as usual. How can I configure Python to use Tk? Thank you, in advance, for any help.
python3 -m tkinter gives the same error message as trying to import it. I tried
sudo apt-get install python-tk and
sudo apt-get install python3-tk but it says it’s already the latest version and doesn’t do anything. I then uninstalled and reinstalled tkinter but that didn’t help.
I updated Python by running these commands (I have wiped the system and done it again, but same issue):
cd ~ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz tar -zxvf Python-3.7.4.tgz cd Python-3.7.4 ./configure make sudo make install
If it’s not installed type in the terminal
sudo apt-get install python3-tk
Testing in python shell
python -m tkinter quite correctly reports No module named tkinter because the Python2 version is Tkinter
python -m Tkinter should work!
There is no need to install tkinter, because it should be included in python3.