0

Method .view() from Python module graphvis gives the error I just try the code from graphvis docs:

# hello.py - http://www.graphviz.org/content/hello
from graphviz import Digraph

g = Digraph('G', filename='hello.gv')
g.edge('Hello', 'World')
g.view()

And I receive the error message:

CalledProcessError: Command '['dot.bat', '-Kdot', '-Tpdf', '-O', 'hello.gv']' returned non-zero exit status 1. [stderr: b'The system cannot find the path specified.\r\n']

By the way - file 'hello.gv.pdf' is created and is Ok. enter image description here

It means - the library installed. Don't work only visualization.
I am working on Windows Anaconda.
I did all possible case installation shown here Nothing changed... 5 hours fly away and - nothing.

Here an example full listing

(Torch_ML) C:\Users\Vasil>python
Python 3.8.8 (default, Feb 24 2021, 15:54:32) [MSC v.1928 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from graphviz import Digraph
>>>
>>> g = Digraph('G', filename='hello.gv')
>>>
>>> g.edge('Hello', 'World')
>>>
>>> print(g)
digraph G {
        Hello -> World
}
>>>
>>> g.view()
The system cannot find the path specified.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Games\Anaconda\envs\Torch_ML\lib\site-packages\graphviz\files.py", line 282, in view
    return self.render(filename=filename, directory=directory,
  File "D:\Games\Anaconda\envs\Torch_ML\lib\site-packages\graphviz\files.py", line 243, in render
    rendered = backend.render(self._engine, format, filepath,
  File "D:\Games\Anaconda\envs\Torch_ML\lib\site-packages\graphviz\backend.py", line 225, in render
    run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet)
  File "D:\Games\Anaconda\envs\Torch_ML\lib\site-packages\graphviz\backend.py", line 185, in run
    raise CalledProcessError(proc.returncode, cmd,
graphviz.backend.CalledProcessError: Command '['dot.bat', '-Kdot', '-Tpdf', '-O', 'hello.gv']' returned non-zero exit status 1. [stderr: b'The system cannot find the path specified.\r\n']
Vasyl Kolomiets
  • 220
  • 5
  • 14

2 Answers2

1

Did you run this code from the terminal or from some python interface? I am assuming this error has to do with the graphic interface.

1

The problem was in graphviz 2.38.2. How to:

It works. But important the sequence of installation. And graohviz 2.38 - does not work. Or I cant work with it

  1. switch to conda-forge chanal
  2. create new environment
  3. (if need) install spaCy, nltk
  4. install pytorch
  5. install jupyter
  6. install graphviz with conda install conda-forge::python-graphviz conda-forge::graphviz=2.46.1
  7. install torchviz with pip install torchviz

and - see here (voila) )) enter image description here

Vasyl Kolomiets
  • 220
  • 5
  • 14