我有以下问题:我在xUbuntu OS上,我正在尝试在Flask应用程序中使用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,但我仍然遇到这个错误。任何想法如何解决这个问题?
答案 0 :(得分:20)
答案 1 :(得分:8)
如果您安装了Anaconda,最简单的方法是从CMD运行以下命令:
conda install pydot-ng
和
conda install graphviz
这需要在路径中添加点。
答案 2 :(得分:5)
确保通过Windows安装程序安装Graphviz(可以从http://www.graphviz.org/Download_windows.php下载)。
然后将bin折叠的路径添加到系统变量“Path”。它是bin fold中的“dot.exe”,由pygraphviz查找。
如果你点击安装graphviz它不起作用。
答案 3 :(得分:0)
在SUSE linux中:
sudo zypper install graphviz
可能有帮助。