pythonpython-3.xtkinterpip

No module named 'tkinter' (Python3.8) in Windows


I have Python3.8.7 and my operating system is Windows. I know that Tkinter module is in the standard library so we don't need to install it. But when I try to import it:

the image that shows the terminal

I also tried to install it: the installing image

(I also looked at the other question in StackOverflow, but it was for Linux and I didn't solve my problem. And also it is too old.)

EDIT: I solved this problem. I executed the installer again and chose the "Modify" option and after that, I chose the "Repair" option. And my problem was solved!


Solution

  • Just re-install python..

    tkinter (and the associated system libraries it needs) are meant to be included by default with any version of python you install. If it got deleted or corrupted (or not installed in the first place), it is easiest often just to re-install python. If you want to keep all the libraries you've already installed, copy c:\Python38\Lib\site-packages somewhere safe, then you can go ahead and delete the python folder. Next you'll want to search using the start menu for "environment variables", and select "edit environment variables for your account". Select the "Path" variable, and click the "edit" button. Delete any entries referring back to the python folder you just deleted.remove old references to the old python installation from the system search path

    The recommended windows installer from python.org for 3.8.7 includes several options if you "customize installation" including whether or not to install tkinter as well as where you want to install.python 3.8.7 64 bit windows installerChecking the entry for "add to PATH" will ensure that when you type "python" into a cmd prompt; it works. You can then move your old "site-packages" folder back to your python folder in the same location "pyfolder\Lib\site-packages". If you install a different version of python you should re-install any libraries rather than copying them, but saving site-packages will at least give you a list of what you need to go install.