我已经下载了graphviz文件并将它们放在我的PC的目录C:\ graphviz中(我正在运行Windows 10)。
然后我将可执行文件的地址添加到系统的PATH中:
在运行诊断代码时仍然如此:
from graphviz import Digraph
dot = Digraph(comment='The Round Table')
dot #doctest: +ELLIPSIS
dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')
dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
print(dot.source) # doctest: +NORMALIZE_WHITESPACE
dot.render('test-output/round-table.gv', view=True) # doctest: +SKIP
我得到一个例外:
// The Round Table
digraph {
A [label="King Arthur"]
B [label="Sir Bedevere the Wise"]
L [label="Sir Lancelot the Brave"]
A -> B
A -> L
B -> L [constraint=false]
}
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\graphviz\backend.py in render(engine, format, filepath, quiet)
128 try:
--> 129 subprocess.check_call(args, stderr=stderr, **POPEN_KWARGS)
130 except OSError as e:
C:\ProgramData\Anaconda3\lib\subprocess.py in check_call(*popenargs, **kwargs)
285 """
--> 286 retcode = call(*popenargs, **kwargs)
287 if retcode:
C:\ProgramData\Anaconda3\lib\subprocess.py in call(timeout, *popenargs, **kwargs)
266 """
--> 267 with Popen(*popenargs, **kwargs) as p:
268 try:
C:\ProgramData\Anaconda3\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, encoding, errors)
706 errread, errwrite,
--> 707 restore_signals, start_new_session)
708 except:
C:\ProgramData\Anaconda3\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_start_new_session)
991 os.fspath(cwd) if cwd is not None else None,
--> 992 startupinfo)
993 finally:
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
ExecutableNotFound Traceback (most recent call last)
<ipython-input-1-1b23fb1e1f3e> in <module>()
14 print(dot.source) # doctest: +NORMALIZE_WHITESPACE
15
---> 16 dot.render('test-output/round-table.gv', view=True) # doctest: +SKIP
C:\ProgramData\Anaconda3\lib\site-packages\graphviz\files.py in render(self, filename, directory, view, cleanup)
174 filepath = self.save(filename, directory)
175
--> 176 rendered = backend.render(self._engine, self._format, filepath)
177
178 if cleanup:
C:\ProgramData\Anaconda3\lib\site-packages\graphviz\backend.py in render(engine, format, filepath, quiet)
130 except OSError as e:
131 if e.errno == errno.ENOENT:
--> 132 raise ExecutableNotFound(args)
133 else: # pragma: no cover
134 raise
ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'test-output/round-table.gv'], make sure the Graphviz executables are on your systems' PATH
几天来我一直在努力解决这个问题。
以下内容也可能有助于诊断:
您的建议将不胜感激。