pydotplus.graphviz.InvocationException: GraphViz's executables not found - installing

463 Views Asked by At

using pycharm, python3.7 with windows 10.

the problematic part of my code is -

import pandas as pd
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import pydotplus  # GraphVis for tree
from sklearn import tree
...
clf = tree.DecisionTreeClassifier()
clf.fit(X_train,y_train)
print("Decision Tree Precision:" + str(clf.score(X_test,y_test)))
dot_data = tree.export_graphviz(clf, out_file=None,
                    feature_names=no_labels.columns, # all columns
                                # without result.
                     class_names=["1","2","3"], # all unique results
                     filled=True, rounded=True,
                     special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data)
graph.write_png('wineTree.png')  # <- problem!
fig, ax = plt.subplots(figsize=(24, 24))
ax.imshow(plt.imread('wineTree.png')) #name
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.show()

i get an error -

Traceback (most recent call last):
  File "C:/Users/ASUS/PycharmProjects/DataProject/clustering/clustering.py", line 66, in <module>
    vis_tree(clf)
  File "C:/Users/ASUS/PycharmProjects/DataProject/clustering/clustering.py", line 35, in vis_tree
    graph.write_png('wineTree.png') #name
  File "C:\Users\ASUS\PycharmProjects\DataProject\venv\lib\site-packages\pydotplus\graphviz.py", line 1810, in <lambda>
    prog=self.prog: self.write(path, format=f, prog=prog)
  File "C:\Users\ASUS\PycharmProjects\DataProject\venv\lib\site-packages\pydotplus\graphviz.py", line 1918, in write
    fobj.write(self.create(prog, format))
  File "C:\Users\ASUS\PycharmProjects\DataProject\venv\lib\site-packages\pydotplus\graphviz.py", line 1960, in create
    'GraphViz\'s executables not found')
pydotplus.graphviz.InvocationException: GraphViz's executables not found

although I imported graphviz 0.14.1 and pydotplus 2.0.2 (latest versions) note - do not user jupyter, tried downloading from https://graphviz.org/download/ -> Stable Windows install packages, got to non existing page. should i download something else?

Thank you!

btw - saw this pydotplus.graphviz.InvocationException: GraphViz's executables not found and - GraphViz's executables not found - Why are there no executables installed after installation of graphViz via pip?

0

There are 0 best solutions below