I'm trying to export a dot file from networkx to visualize an example multigraph using pydot in Spyder, like so:
import networkx as nx
G = nx.MultiGraph()
for i in range(10):
for j in range(3):
G.add_edge(i, i+1, line=j)
nx.draw_networkx(G,pos=nx.spring_layout(G))
from networkx.drawing.nx_pydot import write_dot
write_dot(G,'multi.dot')
import pydot
(graph,) = pydot.graph_from_dot_file('multi.dot')
graph.write_png('multi.png')
Although the dot file is exported as expected, I get this error on the write_png line: FileNotFoundError: [WinError 2] "dot" not found in path.
I installed Graphviz and PyDot in the WinPython command prompt with:
pip install graphviz
pip install pydot
as per similar questions I've seen here. I've also tried restarting both Spyder and the command prompt itself, with no change. What could be causing this?