2025, Nov 16 07:00

Tkinter crashes with X11/xcb assertion when launched via uv? Here's how to fix it by updating uv and resetting your venv

Hit an X11/xcb assertion crash running a simple Tkinter app via uv? It's a known uv bug. Update uv, refresh its Python, remove .venv, and rerun to fix it.

Launching a tiny tkinter window through uv can suddenly explode with a low-level X11/xcb assertion, even though the script itself is trivial and uses no threading. If this sounds familiar, you’re likely hitting a recently fixed bug in uv rather than a problem in your GUI code.

Minimal script that triggers the crash

# file: xxx.py
import tkinter as tk

def start_app():
    ui = tk.Tk()
    caption = tk.Label(ui, text="This line triggers the issue")
    caption.pack()
    ui.mainloop()

if __name__ == "__main__":
    start_app()

How it fails when run via uv

Running the file through uv leads to a hard abort with xcb diagnostics:

uv run xxx.py
Using CPython 3.13.6
Creating virtual environment at: .venv
[xcb] Unknown sequence number while appending request
[xcb] You called XInitThreads, this is not your fault
[xcb] Aborting, sorry about that.
python: xcb_io.c:157: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.

The script doesn’t use threads, and it doesn’t matter—the error appears before your tkinter UI gets a chance to do anything meaningful.

What’s actually wrong

The failure is tied to a bug in uv that has been addressed upstream. If you still have the buggy build on your system, uv run can provision an environment that triggers the xcb assertion on startup. The tkinter code itself is fine.

Fix: update uv, refresh its Python, then clean the local venv

The resolution is straightforward. Update uv to the latest release, refresh the uv-managed Python, and remove any local .venv so the next run is clean.

uv self update
uv python upgrade --reinstall
rm -rf .venv

After that, just run the script again:

uv run xxx.py

If you prefer to run against an explicit interpreter version, that works too:

uv run -p 3.13.6 xxx.py

Why this matters

Toolkit crashes like this one are easy to misdiagnose as application bugs. In reality, the stability of your GUI code often depends on the health of the tooling that provisions and launches it. Keeping uv up to date and resetting environments when something feels off can save hours of fruitless debugging inside tkinter or the X11 stack.

It’s also useful to be aware of ongoing compatibility work. As of 25 Sept 2025, there are known open issues between uv and tkinter; details are tracked here: github.com/astral-sh/uv/issues/15668.

Closing notes

If a minimal tkinter program crashes only when launched via uv, treat the launcher as the prime suspect. Update uv, reinstall the uv-managed Python, and clear the project’s .venv to ensure a fresh start. Once the environment is corrected, the same minimal script should run without touching your code.