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
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")
.