命令 '['dot.bat', '-Kdot', '-Tpdf', '-O', 'hello.gv']' 返回非零退出状态 1. [stderr: b'系统找不到路径指定。\r\n']

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']

来自 Python 模块 graphvis 的方法 .view() 给出了错误 我只是尝试 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()

我收到错误消息:

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']

顺便说一句 - 文件 'hello.gv.pdf' 已创建并且正常。

这意味着 - 安装了库。 不工作只可视化.
我正在研究 Windows Anaconda。
我完成了所有可能的安装案例 没有任何变化...飞了 5 个小时而且 - 什么都没有。

这里是完整列表的示例

(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']

您运行此代码是来自终端还是来自某些python界面? 我假设这个错误与图形界面有关。

问题出在 graphviz 2.38.2。如何:

有效。但重要的是安装顺序。而 graohviz 2.38 - 不工作。或者我无法使用它

  1. 切换到 conda-forge chanal
  2. 创建新环境
  3. (如果需要)安装 spaCy、nltk
  4. 安装pytorch
  5. 安装 jupyter
  6. 使用 conda install conda-forge::python-graphviz conda-forge::graphviz=2.46.1
  7. 安装 graphviz
  8. 使用 pip install torchviz
  9. 安装 torchviz

和 - 看这里(瞧)))