3

The following code:

import pygraphviz as p

def main():
    A=p.AGraph()
    A.add_edge(1,2)
    A.layout(prog="dot")
    A.draw("1.png")

if __name__ == '__main__':
    main()

wokrs fine locally, but when launched via Heroku bash it returns IO Error:

Format: "png" not recognized. Use one of: canon cmap cmapx cmapx_np dot eps fig gv imap imap_np ismap pic plain plain-ext pov ps ps2 svg svgz tk vml vmlz xdot

I used this buildpack to upload graphviz

heroku config:get BUILDPACK_URL
    https://github.com/mfenniak/heroku-buildpack-python-graphviz.git

Here is my requierments.txt file:

Django==1.7.1
argparse==1.2.1
dj-database-url==0.3.0
dj-static==0.0.6
django-toolbelt==0.0.1
gunicorn==19.1.1
psycopg2==2.5.4
pygraphviz==1.3rc2
static3==0.5.1
wsgiref==0.1.2      

Local graphviz version:

dpkg -p graphviz
    Version: 2.26.3-10ubuntu1.1

As for Heroku graphviz version, I am not sure but I found this line in buildpack's bin/compile file:

GRAPHVIZ_BINARY="https://s3-us-west-2.amazonaws.com/mfenniak-graphviz/graphviz-2.30.tgz"

pygraphviz has the same version on Heroku and locally

UPD: How to at least check Heroku's graphviz version?

UPD dot version at heroku does not have png in device section. How to fix that?

dot -v
dot - graphviz version 2.30.1 (20130508.0026)
libdir = "/app/mfenniak/graphviz/lib/graphviz"
Activated plugin library: libgvplugin_dot_layout.so.6
Using layout: dot:dot_layout
Activated plugin library: libgvplugin_core.so.6
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
    /app/mfenniak/graphviz/lib/graphviz/config6
        was successfully loaded.
    render  :  dot fig map pic pov ps svg tk vml xdot
    layout  :  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
    textlayout  : 
    device  :  canon cmap cmapx cmapx_np dot eps fig gv imap imap_np ismap pic plain plain-ext pov ps ps2 svg svgz tk vml vmlz xdot
    loadimage   :  (lib) eps gif jpe jpeg jpg png ps svg

This thread looks similar but unfortunately is not my case. PyGraphViz agraph.layout() throws I0 error

Community
  • 1
  • 1
Sashko Lykhenko
  • 1,554
  • 4
  • 20
  • 36

4 Answers4

4

It looks like there isn't png support in your graphviz executable. Run 'dot -v' to see the supported formats. It looks like e.g. 'svg' is so you could try A.draw("1.svg").

Aric
  • 24,511
  • 5
  • 78
  • 77
  • Looks like I realy do not gave png in device section. Any ideas how to fix that? Updated. – Sashko Lykhenko Nov 06 '14 at 21:39
  • Yep, but no `png` listed in device: – Aric Nov 06 '14 at 21:49
  • Could you suggest how to add it? http://stackoverflow.com/questions/22427184/dot-doesnt-support-any-format-in-a-newly-installed-graphviz Here is kind of answer, but how to do that at Heroku? – Sashko Lykhenko Nov 06 '14 at 22:28
  • I guess you need to install (maybe compile) a version of graphviz with the png support built in. Either that or maybe you can use a different format or convert to png from another format? – Aric Nov 07 '14 at 02:43
  • graphviz-2.30 should support png, shouldn't it? – Sashko Lykhenko Nov 11 '14 at 21:49
  • Yes, graphviz-2.30 does support png but it is optional like many of the device outputs. So you need a version with it configured and compiled in to the binary. – Aric Nov 12 '14 at 01:10
  • could you suggest a direct link to the file in `.tgz` format so that i could replace it in my buildpack code? GRAPHVIZ_BINARY="https://s3-us-west-2.amazonaws.com/mfenniak-graphviz/graphviz-2.30.tgz – Sashko Lykhenko Nov 15 '14 at 22:51
1

I have also met this problem。It bothered me a lot. However, when I happened to type the code below:

import pydot
print pydot.find_graphviz() 

It shows that the path lead to matlab but not Graphviz Then I understand this maybe the reason So I uninstall the matlab and finally solve this problem!

I wonder if your PC also installed matlab, then try this way. May it help you.

xlm
  • 6,854
  • 14
  • 53
  • 55
Bill
  • 21
  • 1
0

I tried re-install graphviz again as suggested in the last ticket, the error is still there. Probably I am not configuring it correctly.

Anyway, if you are using Debian/Ubuntu system.

Try:

sudo apt-get install graphviz

and then:

sudo apt-get install python-pygraphviz
Mark Jin
  • 2,616
  • 3
  • 25
  • 37
0

I faced the same error, and I hope this can help someone who still using the package especially in Windows, just do

dot -c

this will basically configure dot for you

Azzera
  • 1