Jared Moen
Jared Moen

Reputation: 21

Cant import tkinter even though im on windows using python 3

I am trying to run the following code:

import tkinter
tkinter._test

and it says this:

Traceback (most recent call last): File "C:\Users\Desktop\tkintertest", line 1, in import tkinter File "C:\Users\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 37, in import _tkinter # If this fails your Python may not be configured for Tk ModuleNotFoundError: No module named '_tkinter' [Finished in 0.071s]

It is really frustrating because googling just tells me "oh it should work since your on windows using python 3". Well... it doesn't work.

Upvotes: 0

Views: 165

Answers (1)

Roland Smith
Roland Smith

Reputation: 43533

When installing Python using the "Windows Installer", it will install Tk by default. But if "Customize installation" is chosen, that can be switched off. It seems that this is what happened.

Remove and re-install Python using the "Windows installer (64-bit)" from python.org. Either select "Install now", or when choosing "Customize installation" leave the "tcl/tk and IDLE" option on.

Upvotes: 0

Related Questions