InvocationException: GraphViz's executables not found
Posted xyq_idata
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了InvocationException: GraphViz's executables not found相关的知识,希望对你有一定的参考价值。
当我在visualize决策树,运行以下代码时,报错: InvocationException: GraphViz‘s executables not found
import pydotplus from io import StringIO dot_data = StringIO() tree.export_graphviz(clf, out_file=dot_data, feature_names=[‘age‘,‘sex‘,‘1st_class‘,‘2nd_class‘, ‘3rd_class‘]) graph = pydotplus.graph_from_dot_data(dot_data.getvalue()) graph.write_png(‘titanic.png‘) from IPython.core.display import Image Image(filename=‘titanic.png‘)
查阅资料后发现,原来我没有安装GraphViz‘s executables.我是用pip安装的Graphviz,但是Graphviz不是一个python tool,你仍然需要安装GraphViz‘s executables.
problem solved:
You need to install the GraphViz package <http://www.graphviz.org/> so that graph.dag can invoke dot.
安装完之后,再运行还是报错:Exception: "dot.exe" not found in path.
那是因为你没有将GraphViz安装目录的bin目录放到环境变量的path路径中,dot.exe在那个目录下。
Note: 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.
设置完如果还是报同样的错误,你需要重启pyhon IDE.
REF.
[2]http://markmail.org/message/coebrty3itq426c2
[4]http://www.graphviz.org/Download_windows.php
以上是关于InvocationException: GraphViz's executables not found的主要内容,如果未能解决你的问题,请参考以下文章
InvocationException: GraphViz's executables not found
InvocationException: GraphViz‘s exe 解决决策树可视化绘图时报错