小编zal*_*rdo的帖子

Pydot错误:无法识别文件格式"png"

我需要通过pydot构建一个pythonic图解决方案,并尝试运行一个简单的代码,如:

import pydot

graph = pydot.Dot(graph_type='graph')
i=1
edge = pydot.Edge("A", "B%d" % i)
graph.add_edge(edge)
graph.write_png('graph.png')
Run Code Online (Sandbox Code Playgroud)

这是为了在png文件上构建一个简单的图形(A-B1).在解决了很多错误配置后,现在我得到了:

Traceback (most recent call last):
  File "/Users/zallaricardo/Documents/Python/test_png.py", line 7, in <module>
    graph.write_png('graph.png')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py", line 1809, in <lambda>
    lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py", line 1911, in write
    dot_fd.write(self.create(prog, format))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py", line 2023, in create
    status, stderr_output) )
pydot.InvocationException: Program terminated with status: 1. stderr follows: Format: "png" not recognized. Use one of:

logout
Run Code Online (Sandbox Code Playgroud)

到目前为止,找不到我特定环境的直接解决方案.有关如何修复它的任何提示?需要为python 2.7和mac os x 10.9工作. …

python graph graph-visualization python-2.7 pydot

8
推荐指数
1
解决办法
2034
查看次数

标签 统计

graph ×1

graph-visualization ×1

pydot ×1

python ×1

python-2.7 ×1