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.

[1]http://stackoverflow.com/questions/27666846/pydot-invocationexception-graphvizs-executables-not-found

[2]http://markmail.org/message/coebrty3itq426c2

[3]http://stackoverflow.com/questions/18438997/why-is-pydot-unable-to-find-graphvizs-executables-in-windows-8

[4]http://www.graphviz.org/Download_windows.php

转载于:https://www.cnblogs.com/iamxyq/p/5919179.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值