【问题标题】:GraphViz's executables not found error in Anaconda?GraphViz 的可执行文件在 Anaconda 中找不到错误?
【发布时间】:2021-08-09 10:45:11
【问题描述】:

我编写了以下代码来构建决策树,但出现以下错误。你能帮帮我吗?

       from sklearn.tree import DecisionTreeClassifier
       from sklearn.model_selection import train_test_split
       import pandas as pd
       import numpy as np
       from six import StringIO
       from sklearn.tree import export_graphviz
       from sklearn import tree
       import pydot
       from IPython.display import Image
       import pydotplus
       import graphviz
       
       
       dot_data = StringIO()
       export_graphviz(decisionTree1, out_file =dot_data, filled=True,
                       rounded =True, special_characters=True)
       graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
       Image(graph.create_png())

【问题讨论】:

    标签: python python-3.x pandas data-mining decision-tree


    【解决方案1】:
    • 如果您使用的是 Linux,请在 cmd 中尝试:sudo apt-get install graphviz
    • 如果使用 macOS,试试这个brew install graphviz
    • i) 如果在 windows 上通过 conda conda install graphviz 安装它并添加路径环境变量 C:\Users\username\Anaconda3\Library\bin\graphviz
    • ii) 尝试通过conda install python-graphviz 安装它

    【讨论】:

    • 我以前做过,但没有帮助
    • 您使用的是哪个操作系统?
    • ----windows----
    • 你试过conda install python-graphviz
    • 是的,有没有其他方法可以显示不需要这个库的树?
    猜你喜欢
    • 2020-03-05
    • 2018-01-25
    • 2021-10-15
    • 2016-12-18
    • 2018-07-29
    • 2023-03-06
    • 2015-02-24
    • 2017-09-18
    • 2021-03-22
    相关资源
    最近更新 更多