在eclipse中运行pygraphviz 错误(ValueError: Program dot not found in path.)

在macOS系统安装完 pygraphviz后,在终端上运行(python3 test.py)一点问题都没有,可是在eclipse中运行,就出现下面错误:python

Traceback (most recent call last):
  File "/Users/test/Library/Python/3.6/lib/python/site-packages/pygraphviz/agraph.py", line 1293, in _get_prog
    runprog = self._which(prog)
  File "/Users/test/Library/Python/3.6/lib/python/site-packages/pygraphviz/agraph.py", line 1528, in _which
    raise ValueError("No prog %s in path." % name)
ValueError: No prog dot in path.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/test/projects/relation_graph/relation_graph/test_graph2.py", line 13, in <module>
    A.layout(prog='dot')
  File "/Users/zyh/Library/Python/3.6/lib/python/site-packages/pygraphviz/agraph.py", line 1358, in layout
    data = self._run_prog(prog, ' '.join([args, "-T", fmt]))
  File "/Users/test/Library/Python/3.6/lib/python/site-packages/pygraphviz/agraph.py", line 1308, in _run_prog
    runprog = r'"%s"' % self._get_prog(prog)
  File "/Users/test/Library/Python/3.6/lib/python/site-packages/pygraphviz/agraph.py", line 1295, in _get_prog
    raise ValueError("Program %s not found in path." % prog)
ValueError: Program dot not found in path.

参考:https://stackoverflow.com/questions/13987353/python-valueerror-program-dot-not-found-in-patheclipse

解决方法:3d

1. 查出graphviz的安装路径:code

mac-temp:~ zyh$ brew info graphviz
graphviz: stable 2.40.1 (bottled), HEAD
Graph visualization software from AT&T and Bell Labs
https://graphviz.org/
/usr/local/Cellar/graphviz/2.40.1 (500 files, 11.2MB)
  Poured from bottle on 2018-01-09 at 21:01:35

2. 增长变量PATH指向dot的目录:blog





3,再次执行,已经没有错误:ip