Tkinter Designer

← tkinter how-to

How do I fix ModuleNotFoundError: No module named 'tkinter'?

Tkinter is part of the standard library, so this is almost never a pip problem — pip install tkinter will fail, because no such package exists. What is missing is the Tk toolkit your Python was built against. First, confirm it:

python -m tkinter

What that command tells you

A small window appears saying "This is Tcl/Tk version 8.6" — then tkinter is fine and your problem is elsewhere, most likely the wrong interpreter. The same ModuleNotFoundError means the Tk support really is absent, and the fix depends on how Python got onto the machine.

Linux: install the separate package

Most distributions split tkinter out of the main Python package, so a normal Python install genuinely does not include it. This is the single most common cause of the error.

sudo apt install python3-tk        # Debian, Ubuntu, Mint
sudo dnf install python3-tkinter   # Fedora, RHEL
sudo pacman -S tk                  # Arch

macOS: it depends where Python came from

The installer from python.org includes Tk and needs nothing extra. Homebrew's Python does not — it needs a matching python-tk formula, and the version has to line up with your Python. If you use pyenv, Tk has to be present *before* you build the version, so install it and then reinstall Python.

brew install [email protected]       # match your Python version

# pyenv: install Tk first, then rebuild
brew install tcl-tk
pyenv install 3.12.4

Windows: re-run the installer

The official installer has an optional "tcl/tk and IDLE" component. If it was unticked, tkinter is missing. Run the installer again, choose Modify, and make sure that box is checked — no reinstall or path fiddling needed.

Why your virtual environment still fails

A venv borrows the standard library from the Python that created it. Fixing the base interpreter does not retrofit an environment made earlier, so delete the venv and create it again once python -m tkinter works outside it.

One more possibility if you are following an old tutorial: Python 2 spelled it Tkinter with a capital T. On Python 3 it is tkinter, lowercase, and the capitalised import fails on a machine where nothing is actually missing.

Doing it without the lookup

Nothing to install to design the window. The canvas runs in the browser and hands you the Python, so you can lay out the interface while you sort the environment out — and the code you get is plain tkinter, which will run the moment python -m tkinter does.

Lay the window out visually and read the generated Python as you go.

Open the tkinter designer →

Related questions