首页 > 解决方案 > 命令 '['dot.bat', '-Kdot', '-Tpdf', '-O', 'hello.gv']' 返回非零退出状态 1. [stderr: b'系统找不到路径已指定。\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']

标签: pythoncondagraphviz

解决方案


问题出在graphviz 2.38.2. 如何:

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

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

和 - 见这里(瞧))) 在此处输入图像描述


推荐阅读