{"record":{"id":"60b938adb0f03c35","repo":"pola-rs/polars","slug":"the-graphviz-dot-binary-should-be-on-your-path","errorCode":null,"errorMessage":"the graphviz `dot` binary should be on your PATH.(If not installed you can download here: https://graphviz.org/download/)","messagePattern":"the graphviz `dot` binary should be on your PATH\\.\\(If not installed you can download here: https://graphviz\\.org/download/\\)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/various.py","lineNumber":652,"sourceCode":"    output_type = (\n        \"svg\"\n        if (output_path is not None and str(output_path).endswith(\".svg\"))\n        or _in_notebook()\n        or _in_marimo_notebook()\n        or \"POLARS_DOT_SVG_VIEWER\" in os.environ\n        else \"png\"\n    )\n\n    try:\n        graph = subprocess.check_output(\n            [\"dot\", \"-Nshape=box\", \"-T\" + output_type], input=f\"{dot}\".encode()\n        )\n    except (ImportError, FileNotFoundError):\n        msg = (\n            \"the graphviz `dot` binary should be on your PATH.\"\n            \"(If not installed you can download here: https://graphviz.org/download/)\"\n        )\n        raise ImportError(msg) from None\n\n    if output_path:\n        Path(output_path).write_bytes(graph)\n\n    if not show:\n        return None\n\n    if _in_notebook():\n        from IPython.display import SVG, display\n\n        return display(SVG(graph))\n    elif _in_marimo_notebook():\n        import marimo as mo\n\n        return mo.Html(f\"{graph.decode()}\")\n    else:\n        if (cmd := os.environ.get(\"POLARS_DOT_SVG_VIEWER\", None)) is not None:\n            import tempfile","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/various.py#L634-L670","documentation":"Polars raises this ImportError when displaying a query/dependency graph because the external Graphviz `dot` executable cannot be found. Building the DOT source is done in Python, but rendering requires the native graphviz binary installed on the system and discoverable via PATH. Polars deliberately raises with a download link rather than failing silently.","triggerScenarios":"Calling `lf.show_graph()` or `display_dot_graph(...)` (e.g. from LazyFrame.show_graph) when `shutil.which(\"dot\")` fails or the graphviz Python binding cannot spawn the binary — typically because graphviz is not installed or not on PATH.","commonSituations":"Fresh CI containers or Docker images with Python polars pip-installed but the graphviz system package missing; venvs where graphviz was installed to a non-PATH location; Windows machines without graphviz in the system PATH.","solutions":["Install the Graphviz system package: `apt-get install graphviz`, `brew install graphviz`, or `winget install graphviz` / download from https://graphviz.org/download/","Verify the binary is reachable: `dot -V` should print a version; if not, add its directory to PATH","If you only need the DOT source, pass `output_path` and inspect the .dot file without rendering"],"exampleFix":"// before (fails: graphviz not installed)\nlf.show_graph()\n// after (shell)\n# apt-get install graphviz\nlf.show_graph()","handlingStrategy":"fallback","validationCode":"import shutil\nif shutil.which(\"dot\") is None:\n    raise SystemExit(\"graphviz 'dot' binary not found; install graphviz first\")","typeGuard":"def can_render_graph() -> bool:\n    return shutil.which(\"dot\") is not None","tryCatchPattern":"try:\n    lf.show_graph()\nexcept ImportError as e:\n    if \"dot\" in str(e):\n        logging.warning(\"graphviz missing, skipping graph render: %s\", e)\n    else:\n        raise","preventionTips":["Install graphviz as part of your environment bootstrap (Dockerfile/CI image)","Add a smoke test or startup check `shutil.which('dot')`","Document the system dependency next to pip requirements"],"tags":["python","graphviz","environment","dependency"],"backgroundTag":"missing-dependency","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}