本文介绍了PyGraphViz agraph.layout()引发I0错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行以下Python代码后:

After running the following Python code:

import pygraphviz as pgv
G=pgv.AGraph()
G.add_edge(1,2)
G.add_edge(2,3)
G.add_edge(3,4)
G.layout(prog='dot')
G.draw('1.png')

我在IDLE中得到了此跟踪记录:

I got this trace in IDLE:

 File "<pyshell#7>", line 1, in <module>
   G.layout(prog='dot')
 File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 1302, in layout
   data=self._run_prog(prog,' '.join([args,"-T",fmt]))
 File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 1275, in _run_prog
   raise IOError("".join(errors))
 IOError: 'C:\Program' is not recognized as an internal or external command,
 operable program or batch file.

请帮助,我正在做一个课程项目.信息:Graphviz安装正确

Please help, I am working on a course project.Information:Graphviz installed correctedly

推荐答案

您的PyGraphViz和Windows版本似乎是一个错误.我发现此错误通知单对此进行了描述,但显然已在2011年修复.他们实际上还没有发布更新,但是如果可以切换到该版本,它应该在他们的SVN中.

It looks like this is a bug with your version of PyGraphViz and Windows. I found this bug ticket describing it, but it was apparently fixed in 2011. It looks like they haven't actually released the update, but it should be in their SVN if you can switch to that.

如果没有,并且您不介意亲自编辑源,则他们所做的实际修复是真的不重要.只需找到agraph.py,然后更改此行:

If not, and you don't mind editing the source yourself, the actual fix they made is really trivial. Just find agraph.py, and change this line:

runprog=self._get_prog(prog)

runprog=r'"%s"'%self._get_prog(prog)

这篇关于PyGraphViz agraph.layout()引发I0错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:49
查看更多