Pydot Error: "png" file format not recognized

I need to build a pythonic graph solution through pydot and when trying to run simple code, for example:

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

which is designed to build a simple graph (A-B1) in the png file. After fixing many incorrect configurations, now I got:

 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 

And so far I have not been able to find a direct solution for my specific environment. Any hint on how I can fix this? It needs to work for python 2.7 and mac os x 10.9.

My currently installed packages:

 cycler==0.9.0 decorator==4.0.4 graphviz==0.4.7 matplotlib==1.5.0 networkx==1.10 numpy==1.10.1 pydot2==1.0.33 pyparsing==1.5.7 PyPDF2==1.25.1 python-dateutil==2.4.2 pytz==2015.7 six==1.10.0 wheel==0.26.0 

I just wanted to achieve the same result as shown in https://pythonhaven.wordpress.com/2009/12/09/generating_graphs_with_pydot/

+8
python graph graph-visualization pydot
source share
1 answer

Failed to uninstall pydot2 and install pydot ?

 $ pip uninstall pydot2 $ pip install pydot>=1.2.3 

Without any changes to the script, I got the following output

Graph

0
source share

All Articles