Quick answer: Build once with console enabled to read the traceback, fix the missing data/imports, and add an excepthook that writes crashes to a log file for windowed builds.

The flash-and-gone exe has a perfectly good traceback — you just cannot see it. Making the error visible is step one; the fixes are routine after that. Here is the loop.

How to fix it

1. Debug with the console build

Build without --windowed (or run the exe from cmd) — the traceback prints and stays; fix what it names, then switch back to windowed for release.

2. Log uncaught exceptions to a file

Install sys.excepthook at startup that writes the traceback to a file next to the exe (or send it to your error tracker) — windowed builds then leave evidence instead of vanishing.

3. Bundle the data

Missing assets are the top cause: add --add-data "assets;assets" (Windows syntax; colon on macOS/Linux) or list them in the .spec — the exe runs from a temp dir with only what you bundled.

4. Add hidden imports when named

If the traceback says a module is missing that exists in dev, PyInstaller's analysis missed a dynamic import — add --hidden-import name for each.

Catching the ones you can't reproduce

The hardest version of this to fix is the one you can't reproduce — it only happens on a player's hardware, OS, driver, or save state, under conditions that simply aren't present on your machine. A report that says “it crashed” or “it froze” gives you nothing to act on, so the bug survives release after release while quietly costing you players.

Automatic error capture closes that gap. Each failure arrives with its full stack trace, the device and OS, the build number, and a breadcrumb trail of what the player did right before it broke, so even a failure you have never seen becomes a specific, reproducible issue. Fold identical failures into one signature ranked by how many players each hits, and your worklist sorts itself worst-first instead of arriving as a stream of vague complaints.

This is where a tool like Bugnet earns its place. Its SDK captures every Pygame error automatically with the full stack trace plus device, OS, memory, build, and game-state context, folds duplicates into one grouped issue with an occurrence count, and ties each to the build it first appeared on — so you fix the problem that hurts the most players first and confirm it is gone when its signature disappears from the next release.

Most of the time the fix is small. Seeing the failure clearly is the part that actually costs you.