找不到GraphViz的可执行文件(python 3和pydotplus)

找不到GraphViz的可执行文件(python 3和pydotplus),python,machine-learning,graphviz,Python,Machine Learning,Graphviz,我正在努力学习ML,我是个笨蛋。 目前,我正在尝试这个视频 我的代码是: import pydotplus import numpy as np from sklearn.datasets import load_iris from sklearn import tree from sklearn.externals.six import StringIO iris = load_iris() ##print(iris.feature_names) ##print(iris.target_n

我正在努力学习ML,我是个笨蛋。 目前,我正在尝试这个视频

我的代码是:

import pydotplus
import numpy as np
from sklearn.datasets import load_iris
from sklearn import tree
from sklearn.externals.six import StringIO

iris = load_iris()

##print(iris.feature_names)
##print(iris.target_names)
##print(iris.data[0])
##print(iris.target[0])

##for i in range(len(iris.target)):
##    print("Example %d: label %s, features %s" % (i, iris.target[i], iris.data[i]))

test_idx = [0,50,100]

##training data
train_target = np.delete(iris.target, test_idx)
train_data = np.delete(iris.data, test_idx, axis=0)

##testing data
test_target = iris.target[test_idx]
test_data = iris.data[test_idx]

clf = tree.DecisionTreeClassifier()
clf.fit(train_data, train_target)

print(test_target)
print(clf.predict(test_data))

dot_data = StringIO()
tree.export_graphviz(clf,
                     out_file=dot_data,
                     feature_names=iris.feature_names,
                     class_names=iris.target_names,
                     filled=True, rounded=True,
                     impurity=False)

graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf("iris.pdf")
但错误表明:

Traceback (most recent call last):
File "C:\Users\Denis\Desktop\Machine Learning\iris.py", line 42, in graph.write_pdf("iris.pdf")
File "C:\Users\Denis\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pydotplus\graphviz.py", line 1810, in prog=self.prog: self.write(path, format=f, prog=prog)
File "C:\Users\Denis\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pydotplus\graphviz.py", line 1918, in write fobj.write(self.create(prog, format))
File "C:\Users\Denis\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pydotplus\graphviz.py", line 1960, in create 'GraphViz\'s executables not found') pydotplus.graphviz.InvocationException: GraphViz's executables not found
我尝试重新安装pydotplus和graphviz,但没有效果。 我不知道如何改变道路。 我搜索了我的graphviz文件夹,没有找到bin文件


所以,您安装了python的graphviz库,但我想您还没有安装graphviz软件。 您可以从安装它,并确保包含dot可执行文件的目录位于系统的路径上。
祝你旅途好运-

对于所有在windows 10中遇到此问题的用户,即使在尝试了上述步骤(即单独安装Graphviz软件)之后,这对我来说还是有效的-对于尝试调试此错误的windows 10用户,请以管理员重要身份启动CMD!然后运行dot-c,然后运行dot-v
这解决了我的问题

如何确保:包含dot可执行文件的目录位于系统的路径上?我试图下载graphviz-2.38.zip并从上面的屏幕截图中解压缩到同一个文件夹中,但仍然没有找到可执行文件和相同的错误。感谢dilshat的帮助,我通过以下方法添加了我的bin文件夹路径:环境变量->路径