pola-rs/polars · error · ImportError
the graphviz `dot` binary should be on your PATH.(If not…
Error message
the graphviz `dot` binary should be on your PATH.(If not installed you can download here: https://graphviz.org/download/)
What it means
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.
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
Example fix
// before (fails: graphviz not installed) lf.show_graph() // after (shell) # apt-get install graphviz lf.show_graph()
Defensive patterns
Strategy: fallback
Validate before calling
import shutil
if shutil.which("dot") is None:
raise SystemExit("graphviz 'dot' binary not found; install graphviz first") Type guard
def can_render_graph() -> bool:
return shutil.which("dot") is not None Try / catch
try:
lf.show_graph()
except ImportError as e:
if "dot" in str(e):
logging.warning("graphviz missing, skipping graph render: %s", e)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- could not get Databricks token: databricks-sdk is not…
- google-auth must be installed to use `CredentialProviderGCP`
- 'numpy' is required to convert numpy dtype
- pyarrow is required for converting a pandas dataframe to…
- `read_database` queries require at least
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/60b938adb0f03c35.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/_utils/various.py:652
output_type = (
"svg"
if (output_path is not None and str(output_path).endswith(".svg"))
or _in_notebook()
or _in_marimo_notebook()
or "POLARS_DOT_SVG_VIEWER" in os.environ
else "png"
)
try:
graph = subprocess.check_output(
["dot", "-Nshape=box", "-T" + output_type], input=f"{dot}".encode()
)
except (ImportError, FileNotFoundError):
msg = (
"the graphviz `dot` binary should be on your PATH."
"(If not installed you can download here: https://graphviz.org/download/)"
)
raise ImportError(msg) from None
if output_path:
Path(output_path).write_bytes(graph)
if not show:
return None
if _in_notebook():
from IPython.display import SVG, display
return display(SVG(graph))
elif _in_marimo_notebook():
import marimo as mo
return mo.Html(f"{graph.decode()}")
else:
if (cmd := os.environ.get("POLARS_DOT_SVG_VIEWER", None)) is not None:
import tempfileView on GitHub (pinned to fe841f959e)