(Python)的ValueError异常:程序DOT非在路径中找到((Python) ValueE

2019-07-17 11:16发布

我有以下问题:我在Xubuntu的OS,我试图在烧瓶应用程序中使用networkx,和我有下面的代码:

.....
import networkx as nx
......
# Creating and initializing graph object which is networkx object
hosts_graph = get_networkx_graph_object()

# Variable 'coord' where the coordinates for each node will be stored
coord = nx.pygraphviz_layout(hosts_graph, prog = 'dot')

最后一行是一行411我得到以下错误:

File "/home/kiril/Documents/workfolder/omeganoc-sprint/onoc/omeganoc/grapher.py", line 411, in grouping_method
    coord = nx.pygraphviz_layout(hosts_graph, prog = 'dot')
  File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/drawing/nx_agraph.py", line 264, in pygraphviz_layout
    A.layout(prog=prog,args=args)
  File "/usr/local/lib/python2.7/dist-packages/pygraphviz-1.1-py2.7-linux-x86_64.egg/pygraphviz/agraph.py", line 1301, in layout
    data=self._run_prog(prog,' '.join([args,"-T",fmt]))
  File "/usr/local/lib/python2.7/dist-packages/pygraphviz-1.1-py2.7-linux-x86_64.egg/pygraphviz/agraph.py", line 1248, in _run_prog
    runprog=self._get_prog(prog)
  File "/usr/local/lib/python2.7/dist-packages/pygraphviz-1.1-py2.7-linux-x86_64.egg/pygraphviz/agraph.py", line 1236, in _get_prog
    raise ValueError("Program %s not found in path."%prog)
ValueError: Program dot not found in path.

这可能是造成这个问题? 我已经安装networkx和pygraphviz,但我仍然得到这个错误。 任何想法如何解决这个问题?

Answer 1:

PyGraphviz不无Graphviz的工作。 安装太多。



Answer 2:

如果你已经安装了蟒蛇去对此最简单的方法是运行CMD从以下:

conda install pydot-ng

和:

conda install graphviz

这需要增加点到路径的护理。



Answer 3:

确保Graphviz的是通过Windows安装程序安装(可以从下载http://www.graphviz.org/Download_windows.php )。

然后斌倍的路径添加到系统变量“路径”。 这是“dot.exe”在仓折由pygraphviz寻找。

如果你点子安装的graphviz它不工作。



Answer 4:

在SUSE Linux:

sudo zypper install graphviz

可能有帮助。



文章来源: (Python) ValueError: Program dot not found in path