Hi, I am trying to visualize my pymc model using graph and I am not able to execute pm.model_to_graphviz()
I have tried the following -
from pymc import model_to_graphviz
import graphviz
os.environ["PATH"] += os.pathsep + r'/opt/conda/lib/python3.9/site-packages/graphviz'
with model_factory(df):
graphviz = pm.model_to_graphviz()
graphviz
I could not find any .exe file in the graphviz package folder though.
I am getting the following error -
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
/opt/conda/lib/python3.9/site-packages/graphviz/backend/execute.py in run_check(cmd, input_lines, encoding, quiet, **kwargs)
78 kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE
---> 79 proc = _run_input_lines(cmd, input_lines, kwargs=kwargs)
80 else:
/opt/conda/lib/python3.9/site-packages/graphviz/backend/execute.py in _run_input_lines(cmd, input_lines, kwargs)
98 def _run_input_lines(cmd, input_lines, *, kwargs):
---> 99 popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, **kwargs)
100
/opt/conda/lib/python3.9/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,
/opt/conda/lib/python3.9/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, gid, gids, uid, umask, start_new_session)
1818 err_msg = os.strerror(errno_num)
-> 1819 raise child_exception_type(errno_num, err_msg, err_filename)
1820 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot')
The above exception was the direct cause of the following exception:
ExecutableNotFound Traceback (most recent call last)
/opt/conda/lib/python3.9/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
968
969 if method is not None:
--> 970 return method(include=include, exclude=exclude)
971 return None
972 else:
/opt/conda/lib/python3.9/site-packages/graphviz/jupyter_integration.py in _repr_mimebundle_(self, include, exclude, **_)
96 include = set(include) if include is not None else {self._jupyter_mimetype}
97 include -= set(exclude or [])
---> 98 return {mimetype: getattr(self, method_name)()
99 for mimetype, method_name in MIME_TYPES.items()
100 if mimetype in include}
/opt/conda/lib/python3.9/site-packages/graphviz/jupyter_integration.py in <dictcomp>(.0)
96 include = set(include) if include is not None else {self._jupyter_mimetype}
97 include -= set(exclude or [])
---> 98 return {mimetype: getattr(self, method_name)()
99 for mimetype, method_name in MIME_TYPES.items()
100 if mimetype in include}
/opt/conda/lib/python3.9/site-packages/graphviz/jupyter_integration.py in _repr_image_svg_xml(self)
110 def _repr_image_svg_xml(self) -> str:
111 """Return the rendered graph as SVG string."""
--> 112 return self.pipe(format='svg', encoding=SVG_ENCODING)
/opt/conda/lib/python3.9/site-packages/graphviz/piping.py in pipe(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
102 '<?xml version='
103 """
--> 104 return self._pipe_legacy(format,
105 renderer=renderer,
106 formatter=formatter,
/opt/conda/lib/python3.9/site-packages/graphviz/_tools.py in wrapper(*args, **kwargs)
169 category=category)
170
--> 171 return func(*args, **kwargs)
172
173 return wrapper
/opt/conda/lib/python3.9/site-packages/graphviz/piping.py in _pipe_legacy(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
119 engine: typing.Optional[str] = None,
120 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
--> 121 return self._pipe_future(format,
122 renderer=renderer,
123 formatter=formatter,
/opt/conda/lib/python3.9/site-packages/graphviz/piping.py in _pipe_future(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
147 if codecs.lookup(encoding) is codecs.lookup(self.encoding):
148 # common case: both stdin and stdout need the same encoding
--> 149 return self._pipe_lines_string(*args, encoding=encoding, **kwargs)
150 try:
151 raw = self._pipe_lines(*args, input_encoding=self.encoding, **kwargs)
/opt/conda/lib/python3.9/site-packages/graphviz/backend/piping.py in pipe_lines_string(engine, format, input_lines, encoding, renderer, formatter, neato_no_op, quiet)
210 kwargs = {'input_lines': input_lines, 'encoding': encoding}
211
--> 212 proc = execute.run_check(cmd, capture_output=True, quiet=quiet, **kwargs)
213 return proc.stdout
/opt/conda/lib/python3.9/site-packages/graphviz/backend/execute.py in run_check(cmd, input_lines, encoding, quiet, **kwargs)
82 except OSError as e:
83 if e.errno == errno.ENOENT:
---> 84 raise ExecutableNotFound(cmd) from e
85 raise
86
ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH