【问题标题】:Graphviz does not runGraphviz 不运行
【发布时间】:2020-12-10 05:13:42
【问题描述】:

我试图用graphviz显示一个图表,我已经将环境变量添加到系统中,但我可以运行该模块,他继续显示同样的错误

ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'doencasCardiovasculares'], make sure the Graphviz executables are on your systems' PATH

有什么解决办法吗?

这是一个尝试做的事情

import graphviz 
dot_data = tree.export_graphviz(cardio_classificador, out_file=None) 
graph = graphviz.Source(dot_data) 
graph.render("doencasCardiovasculares") 

完整的日志

c:\users\lopes\documents\trabalho_ia\lib\site-packages\graphviz\backend.py in run(cmd, input, capture_output, check, encoding, quiet, **kwargs)
    163     try:
--> 164         proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs)
    165     except OSError as e:

c:\python39\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask)
    946 
--> 947             self._execute_child(args, executable, preexec_fn, close_fds,
    948                                 pass_fds, cwd, env,

c:\python39\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)
   1415             try:
-> 1416                 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1417                                          # no special security

FileNotFoundError: [WinError 2] O sistema não pode encontrar o arquivo especificado

During handling of the above exception, another exception occurred:

ExecutableNotFound                        Traceback (most recent call last)
<ipython-input-13-d199a0947a15> in <module>
      2 dot_data = tree.export_graphviz(cardio_classificador, out_file=None)
      3 graph = graphviz.Source(dot_data)
----> 4 graph.render("doencasCardiovasculares")

c:\users\lopes\documents\trabalho_ia\lib\site-packages\graphviz\files.py in render(self, filename, directory, view, cleanup, format, renderer, formatter, quiet, quiet_view)
    205             format = self._format
    206 
--> 207         rendered = backend.render(self._engine, format, filepath,
    208                                   renderer=renderer, formatter=formatter,
    209                                   quiet=quiet)

c:\users\lopes\documents\trabalho_ia\lib\site-packages\graphviz\backend.py in render(***failed resolving arguments***)
    219         cwd = None
    220 
--> 221     run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet)
    222     return rendered
    223 

c:\users\lopes\documents\trabalho_ia\lib\site-packages\graphviz\backend.py in run(cmd, input, capture_output, check, encoding, quiet, **kwargs)
    165     except OSError as e:
    166         if e.errno == errno.ENOENT:
--> 167             raise ExecutableNotFound(cmd)
    168         else:
    169             raise

ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'doencasCardiovasculares'], make sure the Graphviz executables are on your systems' PATH

【问题讨论】:

  • 你的系统上真的安装了 Graphviz 吗?我不是在谈论 Python graphviz 模块(你肯定已经安装了),我说的是模块作为接口的独立 Graphviz 应用程序。

标签: python graphviz


【解决方案1】:

正如@jasonharper 提到的,您的系统上似乎没有安装graphviz。

尝试使用以下命令安装 graphviz:

sudo apt install graphviz

编辑:

根据@vaettchen 的评论,您似乎使用的是 Windows。所以this link 可能会有所帮助。

【讨论】:

  • `c:\users`...看起来很像Windows,所以应该使用Windows的安装方式
猜你喜欢
  • 1970-01-01
  • 2021-09-28
  • 2018-11-30
  • 2018-02-21
  • 2016-05-05
  • 1970-01-01
  • 2017-07-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多