ijmbarr / causalgraphicalmodels

Causal Graphical Models in Python
MIT License
240 stars 44 forks source link

trouble with running the example #3

Open AffDk opened 3 years ago

AffDk commented 3 years ago

Hi,

I was just trying to play a little with causal graphical models so I started with the provided example.

I ran:

sprinkler = CausalGraphicalModel( nodes=["season", "rain", "sprinkler", "wet", "slippery"], edges=[ ("season", "rain"), ("season", "sprinkler"), ("rain", "wet"), ("sprinkler", "wet"), ("wet", "slippery") ] )

draw return a graphviz dot object, which jupyter can render sprinkler.draw()

and get a long error message:

FileNotFoundError Traceback (most recent call last) ~\AppData\Local\Continuum\anaconda3\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:

~\AppData\Local\Continuum\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, text) 774 errread, errwrite, --> 775 restore_signals, start_new_session) 776 except:

~\AppData\Local\Continuum\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) 1177 os.fspath(cwd) if cwd is not None else None, -> 1178 startupinfo) 1179 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) ~\AppData\Local\Continuum\anaconda3\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:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\graphviz\files.py in repr_svg(self) 111 112 def repr_svg(self): --> 113 return self.pipe(format='svg').decode(self._encoding) 114 115 def pipe(self, format=None, renderer=None, formatter=None, quiet=False):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\graphviz\files.py in pipe(self, format, renderer, formatter, quiet) 136 out = backend.pipe(self._engine, format, data, 137 renderer=renderer, formatter=formatter, --> 138 quiet=quiet) 139 140 return out

~\AppData\Local\Continuum\anaconda3\lib\site-packages\graphviz\backend.py in pipe(engine, format, data, renderer, formatter, quiet) 242 """ 243 cmd, = command(engine, format, None, renderer, formatter) --> 244 out, = run(cmd, input=data, capture_output=True, check=True, quiet=quiet) 245 return out 246

~\AppData\Local\Continuum\anaconda3\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', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

I restarted the kernel a few times and even the computer. Also as suggested in the error message, I added Graphviz to system path but it did not change anything.

Any hint on how I can resolve the issue? Best regards

AffDk commented 3 years ago

I finally installed Graphviz separately and this resolved the issue. I am using windows 10 and apparently Graphviz has some issues on windows:

https://github.com/dask/dask-tutorial/issues/86