码迷,mamicode.com
首页 > 其他好文 > 详细

InvocationException: GraphViz's executables not found

时间:2016-09-29 11:20:18      阅读:655      评论:0      收藏:0      [点我收藏+]

标签:

当我在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

InvocationException: GraphViz's executables not found

标签:

原文地址:http://www.cnblogs.com/iamxyq/p/5919179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!