graphviz - 错误:pydotplus.graphviz.InvocationException:未找到 GraphViz 的可执行文件
问题描述
使用 Windows 10、Python 3.4 IDLE PyCharm 我试图可视化我的模型树,但它不起作用,并且出现以下错误:
import graphviz
from sklearn.tree import export_graphviz
from six import StringIO
from IPython.display import Image
import pydotplus
dot_data = StringIO()
export_graphviz(clf, out_file=dot_data,
filled=True, rounded=True,
special_characters=True,feature_names = list(X_train.columns) ,class_names=['0','1'])
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_png('tree.png')
Image(graph.create_png())
错误是:
# Error : pydotplus.graphviz.InvocationException: GraphViz's executables not found
解决方案
脚步 :
- 安装 App Graphviz ( https://graphviz.org/download/ )
- 安装 graphviz ( pip install graphviz )
- 安装 pydotplus ( pip install pydotplus ) 如果没有正确的环境路径中的应用程序,它将无法工作。
推荐阅读
- c - 如何在链表中访问下一个时修复分段错误错误?
- mysql - 我应该使用哪些数据类型?
- python - 将python列中以毫秒为单位的字符串时间转换为时间戳
- python - Numpy 2-D & 3-D 矩阵“行”乘法
- python - 如何计算 pyspark 数据帧中每两个键之间的相似度?
- gatsby - Gatsby 的 Graphql 说“无法在类型“Query”上查询字段“allMarkdownRemark”并且不会出现 gatsby-transformer-remark
- reactjs - 没有在反应中显示图像上传字段
- python - 如何构建一个返回 txt 中匹配的元素的函数。文件和字典
- angular - Angular 获得意外/无法解释的空引用
- javascript - 未选择按钮时显示错误消息