Search code examples
pythonpython-3.xpython-polarsrust-polars

How to properly set-up Graphviz for Polars on Mac or Windows?


Polars has a powerful feature called df.show_graph(optimized=True).

Have been trying to get this installed on my Windows and Mac computer, system info is below.

Windows
OS = Windows 10
Architecture = x86_64

MacBook
OS = Monterey
Arch= arm64 (Apple Sillicon M1 Mac)


Have installed polars==0.13.40 and installed graphviz==0.20, including matplotlib. Additionally, have added GraphViz and Matplotlib (site-packages) to the PATH environment variable; but still, receive the below error message.

ImportError: Graphviz dot binary should be on your PATH and matplotlib should be installed to show graph.

Could someone please share a simple guide on how to set up Graphviz for Polars via Windows 10 or MacBook (with Apple Sillicon)?

Thanks Jenobi


Solution

  • This is a very common problem.
    graphviz==0.20 is not the actual Graphviz package, it is a Python interface to the Graphviz package. (For more info see https://graphviz.readthedocs.io/en/stable/ - "To render the generated DOT source code, you also need to install Graphviz")
    Go here to find Graphviz: https://graphviz.org/download/