【发布时间】:2017-03-30 16:08:06
【问题描述】:
我在 Windows 7 上运行 Python 的 pydot 时遇到问题。
我安装了 pydot:conda install -c rmg pydot=1.2.2
我在../Program Files (x86)/Graphviz2.38/下安装了graphviz
当我运行以下脚本时,我收到一条错误消息
"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.
我已经尝试过这个解决方案:Permanently adding a file path to sys.path in Python,通过添加 my-paths.pth 文件并带有一行指向
../Graphiv2.38/bin/ dot.exe 文件所在的位置。但我仍然得到错误。
我还能尝试什么?
【问题讨论】:
-
您需要在环境变量 %PATH% 中添加 dot.exe 的绝对路径,而不是相对路径。如果这不起作用,请使用 %PATH% 转储的屏幕截图更新您的帖子。非常重要,Windows 路径仅适用于反斜杠。