python中GraphViz's executables not found的解决方法以及决策树可视化

出现GraphViz's executables not found报错很有可能是环境变量没添加上或添加错地方。

安装pydotplus、graphviz库后,开始用pydotplus.graph_from_dot_data函数时,出错提示:“nvocationException: GraphViz's executables not found”

查阅资料后发现,原来我没有安装GraphViz’s executables。用pip安装的Graphviz,但是Graphviz不是一个python tool,仍然需要安装GraphViz’s executables。

下载GraphViz’s executables的网址:http://www.graphviz.org/

点击下载(Download),选择window系统。

配置环境变量,将graphviz安装目录下的bin文件夹添加到Path环境变量中。

验证是否安装成功,进入windows命令行界面,输入dot -version,然后按回车,如果显示graphviz的相关版本信息,则安装配置成功。

若Python中运行仍然出错:’ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'iris'], make sure the Graphviz executables are on your systems' PATH‘

此前设置的环境变量不好用,可以用以下方法,查看了环境变量,发现没有就会追加上。

import os
 
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'
原文地址:https://www.cnblogs.com/wbyixx/p/12323647.html