VectleSkillsModuleNotFoundError: No module named 'tkinter'

ModuleNotFoundError: No module named 'tkinter'

Export

Third-person routing text. Fixes matplotlib failing with No module named tkinter: the default TkAgg backend needs the tkinter GUI toolkit, which many Python builds omit. Install the python3-tk system package or switch matplotlib to the non-interactive Agg backend. Use when an agent hits this on import matplotlib.pyplot. Not for other missing modules.

TL;DR: matplotlib defaults to the TkAgg backend, which needs tkinter, and your Python was built without it. Install the tkinter system package for your Python, or switch matplotlib to the Agg backend if you do not need interactive windows.

The error

ModuleNotFoundError: No module named 'tkinter'

Fix it

  1. Install tkinter for your OS. On Debian/Ubuntu (match your Python version):
   sudo apt install python3-tk

On Fedora: sudo dnf install python3-tkinter. On macOS with homebrew python it ships included; with python.org builds, reinstall checking the tkinter option. Expected: package installs.

  1. Verify tkinter imports:
   python -c "import tkinter; print('tk ok')"

Expected: prints tk ok.

  1. Retry matplotlib:
   python -c "import matplotlib.pyplot; print('mpl ok')"

Expected: prints mpl ok.

  1. Alternative when no GUI is needed (servers, CI): use the Agg backend before importing pyplot:
   import matplotlib
   matplotlib.use("Agg")
   import matplotlib.pyplot as plt

When this applies

Use this when import matplotlib.pyplot raises the tkinter error, typical on minimal Linux installs, docker images, and some pyenv builds.

When it does not apply

If you need interactive plots on a headless server, Agg alone will not show windows; use a web-based backend or save figures to files. If a different module is missing, that is a separate issue.

Compatibility

All matplotlib versions; the default backend is TkAgg unless configured otherwise.

Root cause

TkAgg renders through Tk, which needs the tkinter bindings compiled into Python. Many system and minimal Python builds skip tkinter, so the backend import fails the moment pyplot loads.

Edge cases

pyenv users must install the tk dev headers and rebuild python to get tkinter. In conda, conda install tk usually fixes it. Setting the MPLBACKEND=Agg environment variable is the zero-code way to force Agg.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=ModuleNotFoundError%3A+No+module+named+%27tkinter%27&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.