首页 > 解决方案 > 错误: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

标签: graphvizpydotplus

解决方案


脚步 :

  • 安装 App Graphviz ( https://graphviz.org/download/ )
  • 安装 graphviz ( pip install graphviz )
  • 安装 pydotplus ( pip install pydotplus ) 如果没有正确的环境路径中的应用程序,它将无法工作。

推荐阅读