"dot.exe" not found in path. Pydot on Python (Windows 7)

Dubraven picture Dubraven · Nov 16, 2016 · Viewed 75.4k times · Source

I'm having trouble running Python's pydot on Windows 7.

I installed pydot with: conda install -c rmg pydot=1.2.2

I have graphviz installed under ../Program Files (x86)/Graphviz2.38/

When I run the following script I get an error saying

"dot.exe" not found in path
import pydot
graph = pydot.Dot(graph_type='digraph')
node_a = pydot.Node("Node A", style="filled", fillcolor="red")
node_b = pydot.Node("Node B", style="filled", fillcolor="green")
node_c = pydot.Node("Node C", style="filled", fillcolor="#0000ff")
node_d = pydot.Node("Node D", style="filled", fillcolor="#976856")
graph.add_node(node_a)
graph.add_node(node_b)
graph.add_node(node_c)
graph.add_node(node_d)
graph.add_edge(pydot.Edge(node_a, node_b))
graph.add_edge(pydot.Edge(node_b, node_c))
graph.add_edge(pydot.Edge(node_c, node_d))
graph.add_edge(pydot.Edge(node_d, node_a, label="and back we go again", labelfontcolor="#009933", fontsize="10.0", color="blue"))
graph.write_png('example2_graph.png')

Exception: "dot.exe" not found in path.

I have tried this solution: Permanently adding a file path to sys.path in Python, by adding the my-paths.pth file with a line pointing to ../Graphiv2.38/bin/ where the dot.exe file is located. But I still get the error.

What else can I try?

Answer

Ernest S Kirubakaran picture Ernest S Kirubakaran · Apr 20, 2017

I followed the instructions given in this blog.

Then I installed graphviz from here and added C:\Program Files (x86)\Graphviz2.38\bin to PATH.

Next I did:

conda install pydot-ng 

And finally in my notebook I added the two lines below.

import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'