0

so I am trying to draw the graph I already have and I constantly run to an error I do not understand.

File "/usr/local/lib/python2.7/site-packages/pygraphviz/agraph.py", line 1305, in layout
    data=self._run_prog(prog,' '.join([args,"-T",fmt]))
File "/usr/local/lib/python2.7/site-packages/pygraphviz/agraph.py", line 1251, in _run_prog
    runprog=r'"%s"'%self._get_prog(prog)
File "/usr/local/lib/python2.7/site-packages/pygraphviz/agraph.py", line 1239, in _get_prog
    raise ValueError("Program %s not found in path."%prog)
ValueError: Program dot not found in path.

But I have installed graphviz with brew and my path works:

Computer:~ name$ dot -V
dot - graphviz version 2.38.0 (20140413.2041)

So what is wrong? Why is the program not found? Thanks!


to draw it i do like this

A=nx.to_agraph(graph)         # convert to a graphviz graph
A.layout(prog='dot')          # neato layout
A.draw(filename+'.png')       # write 
Atais
  • 10,857
  • 6
  • 71
  • 111

2 Answers2

0

I've got a similar setup to you (Mac OSX 10.10, brew) and it is working for me. e.g.

aric:~ aric$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import networkx as nx
>>> A = nx.to_agraph(nx.path_graph(4))
>>> A
<AGraph path_graph(4) <Swig Object of type 'Agraph_t *' at 0x10dbd9600>>
>>> print A
strict graph "path_graph(4)" {
    0 -- 1;
    1 -- 2;
    2 -- 3;
}

>>> A.layout(prog='dot')
>>> A.draw('foo.png')
>>> 
aric:~ aric$ brew -v
Homebrew 0.9.5
aric:~ aric$ uname -a
Darwin aric.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64

Maybe something is wrong with your pygraphviz install?

Try

$ python setup_egg.py test

from the pygraphviz source directory and see if it passes.

You might need to

$pip install doctest-skip-unicode
$pip install nose
Aric
  • 24,511
  • 5
  • 78
  • 77
  • I tried your example and it worked for me too. BUT! The file is not readable (foo.png), and from my Eclipse (with PyDev) it still does not work. :s – Atais Jan 10 '15 at 17:48
  • 1
    Oops it should be A.draw('foo.png') (otherwise you get a dot file). I'll edit the answer. – Aric Jan 10 '15 at 17:58
  • I don't use Eclipse so I'm sorry I can't help you with that environment. – Aric Jan 10 '15 at 17:58
  • Thanks. Well the solution works from the terminal so I am investigaring eclipse now. – Atais Jan 10 '15 at 18:07
0

OK found it digging! It is eclipse fault and PyDev.

And to be exact, the lack of your $PATH in eclipse settings.

Useful links:

OSX + Eclipse + PyDev - PATH isn't correct

Environment variables in Mac OS X


for me worked:

launchctl setenv PATH $PATH

and restart eclipse. you would have to do it everytime you reboot. unfortunately it is an apple bug and you can not do much about it.

The other way round is:

ln -s /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse /usr/local/bin/eclipse

and then start eclipse from terminal:

eclipse &

and the PATH variable will be OK. :(

Community
  • 1
  • 1
Atais
  • 10,857
  • 6
  • 71
  • 111