"dot.exe"在路径中找不到. Python(Windows 7)上的Pydot [英] "dot.exe" not found in path. Pydot on Python (Windows 7)

查看:187
本文介绍了"dot.exe"在路径中找不到. Python(Windows 7)上的Pydot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Windows 7上运行Python的pydot.

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

我使用以下命令安装了pydot:conda install -c rmg pydot=1.2.2

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

我在../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.

我还能尝试什么?

推荐答案

我按照然后我从此处安装了graphviz,并添加了C:\ Program Files(x86)\ Graphviz2. 38 \ bin到PATH.

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

接下来我做了:

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/'

这篇关于"dot.exe"在路径中找不到. Python(Windows 7)上的Pydot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆