Surface missing-Python-package errors clearly in the Quarto log
Build and Deploy Verso / deploy (push) Successful in 14m45s

When a {python} cell fails with ModuleNotFoundError/ImportError, the Quarto
log parser now emits an actionable error ('Python package "X" is not
installed on the server') noting which scientific packages are pre-installed,
instead of leaking an opaque traceback line.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude
2026-06-02 11:32:08 +00:00
parent f1d827202f
commit 96fc1a90a1
@@ -32,6 +32,11 @@ const UPPER_DIAG_REGEX = /^(ERROR|WARNING): (.*)$/
const PANDOC_REGEX = /^\[(WARNING|ERROR|INFO)\] (.*)$/
// knitr/R: `Quitting from lines 3-7 (slides.qmd)`
const R_QUITTING_REGEX = /^Quitting from lines? (\d+)(?:-\d+)?\s*(?:\(([^)]+)\))?/
// Python (Jupyter cell execution): a missing dependency, e.g.
// ModuleNotFoundError: No module named 'pandas'
// ImportError: No module named scipy
const PY_MODULE_REGEX =
/^(?:ModuleNotFoundError|ImportError): No module named ['"]?([\w.]+)['"]?/
// A typst diagnostic location line: ` ┌─ main.typ:5:10` / ` --> main.typ:5:10`
const TYPST_LOCATION_REGEX = /(?:[┌╭]─|-->)\s*(.+?):(\d+):(\d+)/
@@ -67,6 +72,28 @@ export default function parseQuartoLog(rawLog: string): ParseResult {
continue
}
// A missing Python package when executing a {python} cell. Turn the raw
// traceback line into an actionable message rather than letting it slip
// through as an opaque error (or not be surfaced at all).
const pyModule = trimmed.match(PY_MODULE_REGEX)
if (pyModule) {
const pkg = pyModule[1]
data.push({
line: pendingLocation.line ?? null,
file: pendingLocation.file,
level: 'error',
message: `Python package "${pkg}" is not installed on the server`,
content:
`${clean}\n\nThe Python package "${pkg}" is not available in the ` +
`compile environment. Common scientific packages (numpy, pandas, ` +
`scipy, matplotlib, seaborn, scikit-learn, sympy, plotly) are ` +
`pre-installed; others must be added to the server image.`,
raw: clean,
})
pendingLocation = {}
continue
}
let level: LatexLogEntry['level'] | null = null
let message: string | null = null