下記のようなエラーが出ます。
このようにエラーが大量な文で出る時がありますがこれはなぜでしょうか?
この文は木を可視化するコードです
from sklearn.tree import export_graphviz
export_graphviz(tree, out_file="tree.dot", class_names=["malignant", "bennign"],feature_names=cancer.feature_names, impurity=False, filled=True)
import graphviz
with open("tree.dot") as f:
dot_graph = f.read()
graphviz.Source(dot_graph)
エラー
FileNotFoundError Traceback (most recent call last)
/Users/tadashintaro/anaconda/lib/python3.6/site-packages/graphviz/backend.py in pipe(engine, format, data, quiet)
153 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
--> 154 startupinfo=STARTUPINFO)
155 except OSError as e:
/Users/tadashintaro/anaconda/lib/python3.6/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:
/Users/tadashintaro/anaconda/lib/python3.6/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, restore_signals, start_new_session)
1325 err_msg += ': ' + repr(orig_executable)
-> 1326 raise child_exception_type(errno_num, err_msg)
1327 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'dot'
During handling of the above exception, another exception occurred:
ExecutableNotFound Traceback (most recent call last)
/Users/tadashintaro/anaconda/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
309 method = get_real_method(obj, self.print_method)
310 if method is not None:
--> 311 return method()
312 return None
313 else:
/Users/tadashintaro/anaconda/lib/python3.6/site-packages/graphviz/files.py in _repr_svg_(self)
99
100 def _repr_svg_(self):
--> 101 return self.pipe(format='svg').decode(self._encoding)
102
103 def pipe(self, format=None):
/Users/tadashintaro/anaconda/lib/python3.6/site-packages/graphviz/files.py in pipe(self, format)
118 data = text_type(self.source).encode(self._encoding)
119
--> 120 outs = backend.pipe(self._engine, format, data)
121
122 return outs
/Users/tadashintaro/anaconda/lib/python3.6/site-packages/graphviz/backend.py in pipe(engine, format, data, quiet)
155 except OSError as e:
156 if e.errno == errno.ENOENT:
--> 157 raise ExecutableNotFound(args)
158 else: # pragma: no cover
159 raise
ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH
Out[177]:
<graphviz.files.Source at 0x12958e400>
Macを使っています。Python のバージョンは 3.6.1 で、Anaconda を使ってインストールしました。
追記
ターミナルで dot -V
を打った場合 command not found
でした。
dot -V
と打った場合の結果を追記してくださいませんか?dot
がPATH
から見える場所に存在しないのではないかと思っているので、dot -V
の実行結果を(エラーが出たとしても)教えてください。