Graphviz's executables are not found (Python 3.4)

后端 未结 26 1381
故里飘歌
故里飘歌 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:53

    Please use pydotplus instead of pydot

    1. Find:C:\Users\zhangqianyuan\AppData\Local\Programs\Python\Python36\Lib\site-packages\pydotplus

    2. Open graphviz.py

    3. Find line 1925 - line 1972, find the function:

      def create(self, prog=None, format='ps'):
      
    4. In the function find:

      if prog not in self.progs:
          raise InvocationException(
              'GraphViz\'s executable "%s" not found' % prog)
      
      if not os.path.exists(self.progs[prog]) or \
              not os.path.isfile(self.progs[prog]):
          raise InvocationException(
              'GraphViz\'s executable "{}" is not'
              ' a file or doesn\'t exist'.format(self.progs[prog])
          )
      
    5. Between the two blocks add this(Your Graphviz's executable path):

        self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"`
      
    6. After adding the result is:

      if prog not in self.progs:
          raise InvocationException(
              'GraphViz\'s executable "%s" not found' % prog)
      
      self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"
      
      if not os.path.exists(self.progs[prog]) or \
              not os.path.isfile(self.progs[prog]):
          raise InvocationException(
              'GraphViz\'s executable "{}" is not'
              ' a file or doesn\'t exist'.format(self.progs[prog])
          )
      
    7. save the changed file then you can run it successfully.

    8. you'd better save it as bmp file because png file will not work. picture is here

提交回复
热议问题