我试图显示树的输出,但是当我运行下面的脚本时,我会收到一个错误,如下所示:
InvocationException:找不到图形not的可执行文件
我在这里搜索过类似的主题,但大多数都是与Mac相关的。我使用Windows 10 64位操作系统,我使用Anaconda-3 64位.我很想听听你对此的建议。
#Displaying the decision tree
from sklearn import tree
#from StringIO import StringIO
from io import StringIO
#from StringIO import StringIO
from IPython.display import Image
out = StringIO()
tree.export_graphviz(classifier, out_file=out)
import pydotplus
graph=pydotplus.graph_from_dot_data(out.getvalue())
Image(graph.create_png())编辑:我又安装了graphviz和pydotplus模块,但现在还在工作。
发布于 2018-01-21 22:09:16
我也有同样的问题。以下是(Win10,Anaconda3,木星笔记本,python3.x)的解决方案
这个问题是针对不同的操作系统回答的:Graphviz's executables are not found (Python 3.4)
发布于 2019-03-09 02:03:22
我也有类似的问题。和Vamshi一样,我也有类似的Win10系统。我的规范;基于Win10,x64的系统,Anaconda3,AnacondaNavigator1.9.6,Python3.7(确切地说,是Spyder3.3.3)。
我的解决方案还涉及编辑PATH环境变量。这是一个循序渐进的计划:
conda install graphvizPS:您也可以使用pip安装graphviz,但根据我的经验,它可能会导致与使用conda安装的其他模块发生冲突。
发布于 2020-03-23 11:44:35
Vermundir的回答帮助解决了我的问题。
但是,关于步骤9,您需要确定要输入的正确路径。在我的例子中,Python错误不包含任何路径。要找到anaconda3中bin目录的正确路径(需要在其中追加\graphviz),请在ipython上运行以下2行代码:
import os
os.environ 通过扫描os.environ的输出,您将在“path”列表下找到anaconda3 bin目录的路径。例如,您可能会找到这样一条路径:
C:\\Users\\your_username\\AppData\\Local\\Continuum\\anaconda3\\Library\\bin然后将\graphviz追加到该路径,如下所示:
C:\Users\your_username\AppData\Local\Continuum\anaconda3\Library\bin\graphviz 当您单击"New“时,这是您在步骤9中输入的路径。
https://stackoverflow.com/questions/45729624
复制相似问题