Graphviz's executables are not found (Python 3.4)

后端 未结 26 1256
故里飘歌
故里飘歌 2020-11-29 05:00

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         


        
相关标签:
26条回答
  • 2020-11-29 05:42

    I tried setting up Environment variable. Didn't work.I am in Windows environment Combining above methods worked for me :

    1. Downloaded graphviz-2.38.zip from https://graphviz.gitlab.io/_pages/Download/Download_windows.html

    2. Copied the extracted folder into C:\Users\\AppData\Local\Continuum\anaconda3\pkgs\Graphviz2.38

    3. I called the Graphviz location in my code

      Build the classifier

      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)
      

      Build the tree

      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())
      

      Here is how the tree looks:

    0 讨论(0)
  • 2020-11-29 05:43

    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.

    0 讨论(0)
  • 2020-11-29 05:43

    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'

    0 讨论(0)
  • 2020-11-29 05:46

    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

    • Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit
    • add 'C:\Program Files (x86)\Graphviz2.38\bin'
    0 讨论(0)
  • 2020-11-29 05:47

    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

    0 讨论(0)
  • 2020-11-29 05:47

    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.

    0 讨论(0)
提交回复
热议问题