graphviz.backend.ExecutableNotFound: 执行 ['dot', '-Tpng'] 失败,请确保 Graphviz 执行文件在您的系统 PATH 中。

4
我花了一个小时都没有解决这个问题,所以我决定在这里询问。唯一丰富的信息可以在这里找到,但没有详细的说明适用于我的情况。
我使用PyCharm连接离线Ubuntu 16.04服务器,在Windows 10上进行一些机器学习分类的尝试。
代码能够运行到某个点,然后就会抛出以下错误信息。
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.5/site-packages/graphviz/backend.py", line 159, in run
    proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'dot'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/project/2_input/xgboost_loop.py", line 55, in <module>
    xgb.plot_tree(classifier, ax=plt.gca())
  File "/home/user/.local/lib/python3.5/site-packages/xgboost/plotting.py", line 281, in plot_tree
    s.write(g.pipe(format='png'))
  File "/home/user/.local/lib/python3.5/site-packages/graphviz/files.py", line 138, in pipe
    quiet=quiet)
  File "/home/user/.local/lib/python3.5/site-packages/graphviz/backend.py", line 229, in pipe
    out, _ = run(cmd, input=data, capture_output=True, check=True, quiet=quiet)
  File "/home/user/.local/lib/python3.5/site-packages/graphviz/backend.py", line 162, in run
    raise ExecutableNotFound(cmd)
graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Tpng'], make sure the Graphviz executables are on your systems' PATH

Process finished with exit code 1

我通过 pip list 命令检查了一下,在Ubuntu服务器上已经安装了 graphviz 版本为 0.13.2。在给出的链接中建议将 whereis dot 的输出添加到要运行的文件中,如下所示:os.environ["PATH"] += os.pathsep + 'OUTPUT',但是除了 dot: 之外没有任何输出。

在本地,我也检查了我是否安装了相同的 graphviz 版本 0.13.2

2个回答

4

try sudo apt-get install graphviz


1
你需要将Graphviz二进制文件添加到系统的PATH变量中。在我的系统上,路径是C:\Program Files\Graphviz 2.44.1\bin\

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接