carlos-jenkins / pydotplus

PyDotPlus is an improved version of the old pydot project that provides a Python Interface to Graphviz's Dot language.
http://pydotplus.readthedocs.org/
MIT License
75 stars 30 forks source link

pydotplus.graphviz.InvocationException: GraphViz's executables not found #15

Open KimBioInfoStudio opened 6 years ago

KimBioInfoStudio commented 6 years ago

My os info is windows nt 10 x64, When i install the module via pip install pydotplus , then install the latest release GraphViz version is 2.3.8, then put it in my PATH,run dot in the cmd without problem , but when I run it in my pyhton scripts , raise an error: pydotplus.graphviz.InvocationException: GraphViz's executables not found.

My hotfix is: put os.environ["PATH"] += os.pathsep + 'D:/Graphviz2.38/bin/' in site-packages/pydotplus/graphviz.py

Is any fix for my problem?

heator commented 5 years ago

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

@KimBioInfoStudio