From 96fc1a90a19406fa8b8635a648b769d3e834701e Mon Sep 17 00:00:00 2001 From: claude Date: Tue, 2 Jun 2026 11:32:08 +0000 Subject: [PATCH] Surface missing-Python-package errors clearly in the Quarto log 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 --- .../js/ide/log-parser/quarto-log-parser.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/services/web/frontend/js/ide/log-parser/quarto-log-parser.ts b/services/web/frontend/js/ide/log-parser/quarto-log-parser.ts index 8362bb2997..a6bac19ad9 100644 --- a/services/web/frontend/js/ide/log-parser/quarto-log-parser.ts +++ b/services/web/frontend/js/ide/log-parser/quarto-log-parser.ts @@ -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