Python pydot.InvocationException:找不到 GraphViz 的可执行文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27666846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 02:05:16  来源:igfitidea点击:

pydot.InvocationException: GraphViz's executables not found

pythonscipygraphvizpydot

提问by Chewbacca

I try to run this examplefor decision tree learning, but get the following error message:

我尝试运行此示例进行决策树学习,但收到以下错误消息:

File "coco.py", line 18, in graph.write_pdf("iris.pdf") File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py", line 1602, in lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog)) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py", line 1696, in write dot_fd.write(self.create(prog, format)) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py", line 1727, in create 'GraphViz\'s executables not found' ) pydot.InvocationException: GraphViz's executables not found

文件“coco.py”,第 18 行,在 graph.write_pdf(“iris.pdf”) 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pydot.py” ,第 1602 行,在 lambda 路径中,f=frmt, prog=self.prog : self.write(path, format=f, prog=prog)) 文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/ python2.7/site-packages/pydot.py", line 1696, in write dot_fd.write(self.create(prog, format)) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2. 7/site-packages/pydot.py", line 1727, in create 'GraphViz\'s executables not found') pydot.InvocationException: GraphViz's executables not found

I saw this postabout a similar error, but even when I follow their solution (uninstall and then reinstall graphviz and pydot in the opposite order) the problem continues... I'm using MacOS (Yosemite).

我看到这篇关于类似错误的帖子,但即使我按照他们的解决方案(卸载然后以相反的顺序重新安装 graphviz 和 pydot),问题仍然存在......我正在使用 MacOS(优胜美地)。

Any ideas? Would appreciate the help.

有任何想法吗?将不胜感激的帮助。

回答by Akavall

cel, answered this in the comment:

cel,在评论中回答了这个:

Graphviz is not a python tool. The python packages at pypi provide a convenient way of using Graphviz in python code. You still have to install the Graphviz executables, which are not pythonic, thus not shipped with these packages. You can install those e.g. with a general-purpose package manager such as homebrew

Graphviz 不是 Python 工具。pypi 中的 python 包提供了一种在 python 代码中使用 Graphviz 的便捷方法。您仍然需要安装 Graphviz 可执行文件,它们不是 Pythonic,因此不会随这些软件包一起提供。您可以使用通用包管理器(例如自制软件)安装它们

For me personally, on ubuntu 14.04, all I had to do is:

就我个人而言,在 ubuntu 14.04 上,我所要做的就是:

sudo apt-get install graphviz

回答by djurikom

I had the same issue when installing pydot and graphviz with pip, then I found the answer here.

我在用 pip 安装 pydot 和 graphviz 时遇到了同样的问题,然后我在这里找到了答案。

In particular, I first uninstalled pydot and graphviz which I separately installed using pip (using sudo pip uninstall pydotand the same for graphviz). Then, I run sudo apt-get install python-pydotwhich fixed the issue.

特别是,我首先卸载了我使用 pip 单独安装的 pydot 和 graphviz(使用sudo pip uninstall pydot和 相同graphviz)。然后,我运行sudo apt-get install python-pydot它解决了这个问题。

回答by Milind Patil

I was facing the same issues, my problem got resolved using:

我遇到了同样的问题,使用以下方法解决了我的问题:

  1. Run the command sudo port install graphviz
  2. If error is coming for the port then first install port from below based on the version you are using https://guide.macports.org/chunked/installing.macports.html
  3. After installation of port run command sudo port install graphviz
  1. 运行命令 sudo port install graphviz
  2. 如果端口出现错误,则首先根据您使用的版本从下面安装端口 https://guide.macports.org/chunked/installing.macports.html
  3. 安装端口运行命令后 sudo port install graphviz

Restart the python kernel if you are using iPython and run again.

如果您使用的是 iPython,请重新启动 python 内核并再次运行。

回答by Matiji66

For windows users:
1.install Graphviz
2.Add Graphviz path to PATH variable
3.Restart PyCharm or other compiler.

对于 Windows 用户: 1.
安装 Graphviz 2.将
Graphviz 路径添加到 PATH 变量
3.重新启动 PyCharm 或其他编译器。

As of version 2.31, the Visual Studio package no longer alters the PATH variable or accesses the registry at all. If you wish to use the command-line interface to Graphviz or are using some other program that calls a Graphviz program, you will need to set the PATH variable yourself.

从 2.31 版开始,Visual Studio 包不再改变 PATH 变量或访问注册表。如果您希望使用 Graphviz 的命令行界面或正在使用调用 Graphviz 程序的其他程序,则需要自己设置 PATH 变量。

回答by Maksim Panfilov

On Windows 8 this solved the same problem for me:

在 Windows 8 上,这为我解决了同样的问题:

import os     
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'

回答by Mark

brew install graphviz
pip install -U pydotplus

... worked for me on MacOSX

... 在 MacOSX 上为我工作

回答by scarain

conda install -c anaconda graphviz        
conda install -c anaconda pydot

回答by Liky

On mac, use Brew to install graphviz and not pip, see links:

在 Mac 上,使用 Brew 安装 graphviz 而不是 pip,请参阅链接:

graphviz information: http://www.graphviz.org/download/

graphviz 信息:http: //www.graphviz.org/download/

brew installation: https://brew.sh/

brew 安装:https: //brew.sh/

So typing the following in the terminal after you install brew should work:

因此,安装 brew 后在终端中键入以下内容应该可以工作:

brew install graphviz

回答by Kradcifer

Worked for me on Ubuntu 18.04 as well:

在 Ubuntu 18.04 上也为我工作:

$ sudo apt-get install graphviz  

回答by SEM

I did face similar issue and the way it was corrected was by changing the path.

我确实遇到过类似的问题,解决方法是改变路径。

This is what I did :

这就是我所做的:

Copy paste "graphiz" path from your computer to Environment variable>Path from the control panel

将“graphiz”路径从您的计算机复制到环境变量>控制面板中的路径

Example: Graphiz path : C:\Apps\Program Files\Continuum\Anaconda2\Library\bin\graphviz)

示例:Graphiz 路径:C:\Apps\Program Files\Continuum\Anaconda2\Library\bin\graphviz)

(I had installed it on Apps folder. It could be in a diff path for you)

(我已将它安装在 Apps 文件夹中。它可能位于不同的路径中)

Setting path in Environment Variable :

在环境变量中设置路径:

Go to Control Panel>Control Panel\System and Security\System .Click Advanced Setting and then Advanced .You'll find Environment variables at bottom right. Click Path to edit and save it . Close your IDE and re open it .

转到控制面板>控制面板\系统和安全\系统。单击高级设置,然后单击高级。您将在右下角找到环境变量。单击“路径”进行编辑并保存。关闭您的 IDE 并重新打开它。

It worked for me .

它对我有用。