{"record":{"id":"6da59f43356d480e","repo":"docling-project/docling","slug":"plotting-requires-matplotlib-install-it-in-the-en","errorCode":null,"errorMessage":"Plotting requires matplotlib. Install it in the environment first.","messagePattern":"Plotting requires matplotlib\\. Install it in the environment first\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"perfs/plot_memory_metrics.py","lineNumber":120,"sourceCode":"\n            if event == \"loaded\":\n                memory_loaded = payload.get(\"memory_loaded_mb\")\n                if isinstance(memory_loaded, dict):\n                    total_pages.append(total_page_no)\n                    _append_memory_values(loaded_metrics, memory_loaded)\n\n    return total_pages, loaded_metrics\n\n\ndef main() -> None:\n    args = parse_args()\n    if not args.input_file.is_file():\n        raise SystemExit(f\"Input file does not exist: {args.input_file}\")\n\n    try:\n        import matplotlib.pyplot as plt\n    except ImportError as exc:\n        raise SystemExit(\n            \"Plotting requires matplotlib. Install it in the environment first.\"\n        ) from exc\n\n    loaded_runs = []\n    for label, metrics_file in _resolve_metrics_files(args.input_file):\n        if not metrics_file.is_file():\n            raise SystemExit(f\"Metrics file does not exist: {metrics_file}\")\n        total_pages, loaded_metrics = load_points(metrics_file)\n        if total_pages:\n            loaded_runs.append((label, total_pages, loaded_metrics))\n\n    if not loaded_runs:\n        raise SystemExit(f\"No plotable data found in {args.input_file}\")\n\n    fig, ax = plt.subplots(1, 1, figsize=(12, 6))\n\n    for label, total_pages, loaded_metrics in loaded_runs:\n        point_count = min(","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/perfs/plot_memory_metrics.py#L102-L138","documentation":"SystemExit raised by main() in perfs/plot_memory_metrics.py when 'import matplotlib.pyplot' fails with ImportError. matplotlib is an optional dependency used only for rendering the memory-over-time plot, so the script gives an actionable install message instead of a traceback.","triggerScenarios":"Running plot_memory_metrics.py in any environment where matplotlib is absent — e.g. the docling runtime venv, a slim container, or a linting/production image that intentionally excludes plotting libraries.","commonSituations":"Performance benchmarking environments provisioned with only the packages needed to run conversions; CI images that minimize size; Python environments where matplotlib was uninstalled or never added to requirements.","solutions":["Install matplotlib in the same environment: 'pip install matplotlib' (or 'uv pip install matplotlib').","Add matplotlib to the perf tooling's requirements/dev extras so benchmark environments always include it.","If you only need the numbers, skip plotting and read the .jsonl metrics directly instead."],"exampleFix":"# before\n$ uv run python perfs/plot_memory_metrics.py summary.json\n# SystemExit: Plotting requires matplotlib. Install it in the environment first.\n\n# after\n$ uv pip install matplotlib\n$ uv run python perfs/plot_memory_metrics.py summary.json","handlingStrategy":"try-catch","validationCode":"try:\n    import matplotlib.pyplot  # noqa: F401\nexcept ImportError:\n    raise SystemExit(\"Install matplotlib: pip install matplotlib\")","typeGuard":null,"tryCatchPattern":"try:\n    import matplotlib.pyplot as plt\nexcept ImportError:\n    plt = None\n\nif plt is None:\n    # export the series as CSV/JSON instead of plotting\n    ...","preventionTips":["Include matplotlib in the perf tooling requirements file.","Provision a plotting stage in CI with matplotlib preinstalled.","When plotting is optional, degrade to writing the data series instead of failing."],"tags":["perf-tooling","matplotlib","dependency","cli"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}