【问题标题】:failed to execute ['dot', '-Kdot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH未能执行 ['dot', '-Kdot', '-Tsvg'],请确保 Graphviz 可执行文件位于您系统的 PATH 中
【发布时间】:2021-04-23 00:37:57
【问题描述】:

我将它与我的数据库中的决策树模型一起使用:

dot_data = tree.export_graphviz(pipeline.named_steps['classifier'], out_file=None, 
                         feature_names = categorical_feature_names + numerical_features,
                         class_names=[str(el) for el in pipeline.named_steps.classifier.classes_],  
                         filled=True, rounded=True,  
                         special_characters=True)  
graph = graphviz.Source(dot_data) 
graph

它给了我这个错误:

failed to execute ['dot', '-Kdot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

我在这里阅读,而不是在我的笔记本上安装它以获得正确的路径:https://github.com/xflr6/graphviz/issues/68

我是这样写的:conda install -c conda-forge python-graphviz

就像这样:conda install python-graphviz

Botk 工作,但他们都没有解决错误,我仍然得到了她。

有人知道如何解决此错误?

谢谢。

【问题讨论】:

  • 您显然还没有安装 GraphViz。 python-graphviz 只是一个用于与应用程序对话的 Python 模块,而不是应用程序本身。

标签: python python-3.x graphviz


【解决方案1】:

您需要将 graphviz 可执行文件添加到您的 PATH。不是用 conda 或 pip 安装模块的问题。这是我使用 Mac 的解决方案:

  1. 打开终端输入vim .zshrc(我用zsh)
  2. 插入export PATH="/usr/local/opt/graphviz/bin:$PATH"
  3. 保存并退出 (:wq)

这对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-16
    • 2016-05-05
    • 2020-05-25
    • 2016-12-18
    • 2018-07-29
    • 2023-03-06
    • 2015-02-24
    相关资源
    最近更新 更多