Graphviz's executables are not found (Python 3.4)

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

I am running Python3.4 on Windows 7. I am trying to use the Python interface for graphviz. This is a script I intend to run:

from graphviz import Digraph import pydotplus  dot = Digraph(comment='The Round Table')  dot.node('A', 'King Arthur') dot.node('B', 'Sir Bedevere the Wise') dot.node('L', 'Sir Lancelot the Brave') dot.edges(['AB', 'AL']) dot.edge('B', 'L', constraint='false')  print(dot.source) dot.render('test-output/round-table.gv', view=True)

I get the following error at runtime:

RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test-output/round-table.gv'], make sure the Graphviz executables are on your systems' path

Now I am sure I have properly installed the correct dependencies. I first tried to set the correct environment variables. The graphviz executables are located at C:\Program Files (x86)\Graphviz2.37\bin so I went to the Environment Variables section. There are two sections there: User Variables and System Variables. Under System Variables I clicked on Path and then clicked Edit and added ;C:\Program Files (x86)\Graphviz2.37\bin to the end of the string and saved. This didn't clear the error.

Then, following the answer given here I uninstalled pydot (actually I use pydotplus here) and re-installed it again, but still no success.

I have been trying for hours to fix this and the whole PATH variable thing is just confusing and frustrating.

回答1:

On jupyter(ipython) notebook with anaconda in win10 I solved the problem by conda install graphviz after I had installed graphviz by pip install graphviz



回答2:

In my case (Win10, Anaconda3, Jupyter notebook) after "conda install graphviz" I have to add to the PATH: C:\Users\username\Anaconda3\Library\bin\graphviz

To modify PATH goto Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit > New



回答3:

when you add C:\Program Files (x86)\Graphviz2.38\bin to PATH, then you must close your IDE enviroment such as spyder and restart, you'll solve the "RuntimeError:make sure the Graphviz executables are on your systems' path"



回答4:

I also had this problem on Ubuntu 16.04.

Fixed by running sudo apt-get install graphviz in addition to the pip install I had already performed.



回答5:

As it appears, Graphviz2.37 is known to have problems with the PATH variable on windows. I uninstalled it, removed the environment variables associated with it and instead downloaded and installed the newer beta version from here and it now works like a charm.



回答6:

To solve this problem,when you install graphviz2.38 successfully, then add your PATH variable to system path.Under System Variables you can click on Path and then clicked Edit and added ;C:\Program Files (x86)\Graphviz2.38\bin to the end of the string and saved.After that,restart your pythonIDE like spyper,then it works well.

Don't forget to close Spyder and then restart.



回答7:

I solved it installing directly from https://graphviz.gitlab.io/_pages/Download/Download_windows.html and including in windows path:

C:\Program Files (x86)\Graphviz2.38\bin  C:\Program Files (x86)\Graphviz2.38

After I restart windows



回答8:

For windows 8.1 & python 2.7 , I fixed the problem by following below steps

1 . Download and install graphviz-2.38.msi http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.38.msi

2 . Set the path variable

  • Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit
  • add 'C:\Program Files (x86)\Graphviz2.38\bin'


回答9:

I had the same issue with Windows 10.

First, I installed graphviz-2.38.0 with the following command without any problem...

install -c anaconda graphviz=2.38.0

Second, I installed pydotplus with the following command without any problem...

install -c conda-forge pydotplus

After that, when I got to my step to visualize my decision tree had the following issue with {InvocationException: GraphViz's executables not found}...

C:\Users\admin\Anaconda3\lib\site-packages\pydotplus\graphviz.py in create(self, prog, format)    1958             if self.progs is None:    1959                 raise InvocationException( -> 1960                     'GraphViz\'s executables not found')    1961     1962         if prog not in self.progs:  InvocationException: GraphViz's executables not found

In my case, all I had to do to fix it is to put the environment path of the graphviz executables in my user PATH environment variable and this fixed it. Just make sure it is the path where YOUR.exe files are located :)

C:\Users\admin\Anaconda3\pkgs\graphviz-2.38.0-4\Library\bin\graphviz


回答10:

Because Mac OS has not been mentioned I will add that I had the same problem on OS X Yosemite, the solution I found was to do brew install graphviz

This solved the problem, not sure if I shouldn't have just edited one of the other answers in this list, because they all seem to be the same answer, just install an official package in addition to the Python Library.



回答11:

Just install

conda install graphviz

then install

conda install -c conda-forge pydotplus


回答12:

I had the same issue on Ubuntu(14.04) with Jupyter.

To solve it I've added the dot library to python sys.path

First: check if dot is installed,

Then: find his path whereis dot -> /local/notebook/miniconda2/envs/ik2/bin/dot

Finally in python script : sys.path.append("/local/notebook/miniconda2/envs/ik2/bin/dot")



回答13:

I'm using Windows 10, Python 3.6 on Anaconda 3 and have faced the same issue.

I've had it work by doing the following in sequence:

  1. From Anaconda Terminal: pip install pydotplus
  2. From Anaconda Terminal: conda install pydotplus
  3. From Anaconda Terminal: pip install graphviz
  4. From Anaconda Terminal: conda install graphviz
  5. Went to Windows Environment Varialbes, PATH, and added the location of my dot.exe file under graphviz directory in Anaconda.

worked fine after that.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!