I am running Python3.4 on Windows 7. I am trying to use the Python interface for graphviz. This is a script I intend to run:
from graphviz import Digraph
imp
I tried setting up Environment variable. Didn't work.I am in Windows environment Combining above methods worked for me :
Downloaded graphviz-2.38.zip from https://graphviz.gitlab.io/_pages/Download/Download_windows.html
Copied the extracted folder into C:\Users\\AppData\Local\Continuum\anaconda3\pkgs\Graphviz2.38
I called the Graphviz location in my code
import sklearn.datasets as datasets
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
iris=datasets.load_iris()
df=pd.DataFrame(iris.data, columns=iris.feature_names)
y=iris.target
dtree=DecisionTreeClassifier()
dtree.fit(df,y)
from sklearn.externals.six import StringIO
from IPython.display import Image
from sklearn.tree import export_graphviz
import pydotplus
import graphviz
import os
os.environ\["PATH"\] += os.pathsep + 'C:/Users/tstusr/AppData/Local/Continuum/anaconda3/pkgs/Graphviz2.38/bin'
dot_data = StringIO()
export_graphviz(dtree, out_file=dot_data,
filled=True, rounded=True,
special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())
As it appears, Graphviz2.37 is known to have problems with the PATH variable on windows. I uninstalled it, removed the environment variables associated with it and instead downloaded and installed the newer beta version 2.39 and it now works like a charm.
Tried many ways and here is what really solved the problem - it worked for both windows 8.1/10 & python 3 .
1 . pip install graphviz
2 . the key action needed is to set the path variable by following steps below:
a. Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit b. add 'C:\Program Files (x86)\Graphviz2.38\bin'
For windows 8.1 & python 2.7 , I fixed the problem by following below steps
1 . Download and install graphviz-2.38.msi http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.38.msi
2 . Set the path variable
I solved it installing directly from https://graphviz.gitlab.io/_pages/Download/Download_windows.html
and including in windows path:
C:\Program Files (x86)\Graphviz2.38\bin
C:\Program Files (x86)\Graphviz2.38
After I restart windows
I am not sure if this is an answer to THIS question, but this also seems to be the "how do I get graphviz to run on my setup?" thread. I also did not see python-graphviz
mentioned anywhere.
As such: Ubuntu 16.04, conda Python 3.7, using Jupyter notebooks.
conda install -c anaconda graphviz
conda install -c conda-forge python-graphviz
The images would not render after trying only the first command; they did render after running the second.
I also installed pydot-plus
, but did not see any change in behavior, performance, or image resolution.