1. 程式人生 > >[bug] ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are

[bug] ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are

when calling sklearn.tree.export.export_graphviz() I encountered this error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
E:\Anaconda3\envs\fastai\lib\site-packages\graphviz\backend.py in run(cmd,
input, capture_output, check, quiet, **kwargs) 146 try: --> 147 proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs) 148 except OSError as e: E:\Anaconda3\envs\fastai\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) 708 errread, errwrite, --> 709 restore_signals, start_new_session) 710 except: E:
\Anaconda3\envs\fastai\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) 996 os.fspath(cwd) if cwd is not None else None, --> 997 startupinfo) 998 finally: FileNotFoundError: [WinError 2] 系統找不到指定的檔案。 During handling of the above exception, another exception occurred: ExecutableNotFound Traceback (most recent call last) E:\Anaconda3\envs\fastai\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method is not None: --> 345 return method() 346 return None 347 else: E:\Anaconda3\envs\fastai\lib\site-packages\graphviz\files.py in _repr_svg_(self) 104 105 def _repr_svg_(self): --> 106 return self.pipe(format='svg').decode(self._encoding) 107 108 def pipe(self, format=None, renderer=None, formatter=None): E:\Anaconda3\envs\fastai\lib\site-packages\graphviz\files.py in pipe(self, format, renderer, formatter) 126 data = text_type(self.source).encode(self._encoding) 127 --> 128 out = backend.pipe(self._engine, format, data, renderer, formatter) 129 130 return out E:\Anaconda3\envs\fastai\lib\site-packages\graphviz\backend.py in pipe(engine, format, data, renderer, formatter, quiet) 204 """ 205 cmd, _ = command(engine, format, None, renderer, formatter) --> 206 out, _ = run(cmd, input=data, capture_output=True, check=True, quiet=quiet) 207 return out 208 E:\Anaconda3\envs\fastai\lib\site-packages\graphviz\backend.py in run(cmd, input, capture_output, check, quiet, **kwargs) 148 except OSError as e: 149 if e.errno == errno.ENOENT: --> 150 raise ExecutableNotFound(cmd) 151 else: # pragma: no cover 152 raise ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

I’ve tried to import graphviz but it failed

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-f7133d3517ab> in <module>
----> 1 import graphviz

ModuleNotFoundError: No module named 'graphviz'

Following this, I pip install graphviz after conda install graphviz (prior error occurs after only conda install the library) But I still failed.