Skip to content
Latchkey

papermill "PapermillExecutionError" in CI

papermill executes a notebook cell by cell and, unlike a silent run, writes the partially-executed output notebook so you can inspect it. When a cell raises, papermill records the error in that output and re-raises a PapermillExecutionError naming the cell index and the original exception.

What this error means

papermill exits non-zero with "papermill.exceptions.PapermillExecutionError" that reports the failing cell number, the exception type, and the original message.

papermill
papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [4]":
KeyError: 'revenue'

Common causes

A cell genuinely raised during execution

The notebook code failed for the given parameters or inputs: a bad key, a missing file, or a runtime error that surfaces in CI.

Wrong or missing parameters changed the code path

Parameters injected by papermill drove the notebook into a branch that errors, for example an empty or unexpected input value.

How to fix it

Open the saved output notebook

  1. Read the cell index named in the PapermillExecutionError.
  2. Open the output notebook papermill wrote to see the full traceback and the injected parameters cell.
  3. Fix the code or the parameters that drove the failing branch.
Terminal
papermill input.ipynb output.ipynb -p region us-east -p threshold 10

Validate parameters before the heavy cells

Add an early assertion cell so bad parameters fail fast with a clear message rather than deep in the notebook.

How to prevent it

  • Archive the output notebook as a CI artifact so failures are inspectable.
  • Assert on injected parameters early in the notebook.
  • Test the notebook with representative parameters locally before CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →