1

I am trying to run this script https://github.com/dennybritz/nn-theano/blob/master/nn-theano.ipynb which implements a neural network using theano.

All goes fine until I get to the cell:

theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, outfile='img/nn-theano-forward_prop.png', format='png')
SVG(theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, return_image=True, format='svg'))

Then I get this error:

RuntimeError                              Traceback (most recent call last)
<ipython-input-11-db44e43f05ee> in <module>()
----> 1 theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, outfile='img/nn-theano-forward_prop.png', format='png')
      2 SVG(theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, return_image=True, format='svg'))

~\Anaconda3\lib\site-packages\theano\printing.py in pydotprint(fct, outfile, compact, format, with_ids, high_contrast, cond_highlight, colorCodes, max_label_size, scan_graphs, var_with_name_simple, print_output_file, return_image) 781 " and either pydot or pydot-ng for " 782 "pydotprint to work.", --> 783 pydot_imported_msg) 784 785 g = pd.Dot()

RuntimeError: ('Failed to import pydot. You must install graphviz and either pydot or pydot-ng for `pydotprint` to work.', 'An error happened while importing/trying pydot: (2, \'"dot.exe" not found in path.\', None, 2, None)')

I have read other questions on Stack and have tried installing graphviz via https://graphviz.gitlab.io/

I have pydot, pydotplus, graphviz (2.38.0) and also python-graphviz (0.8.2) installed. I am using Anaconda Navigator which I have recently updated. Python 3.6.4 Windows 10 32bit.

ZF007
  • 3,708
  • 8
  • 29
  • 48
Michael
  • 87
  • 2
  • 9

2 Answers2

1

GraphViz executables need to be in the $PATH variable for pydot to find them. Please see: https://stackoverflow.com/a/47209738/1959808

pydotplus is an unmaintained fork of pydot.

0 _
  • 10,524
  • 11
  • 77
  • 109
  • Thank you for your answer. Is GraphViz different to graphviz? How do i find out exactly what needs to be added to the $PATH variable? – Michael Apr 13 '18 at 08:28
  • [GraphViz](https://www.graphviz.org/) plots graphs. I use capitalization to emphasize that there is no executable named [`graphviz`, and also to avoid confusion with the Python package `graphviz`](https://pypi.python.org/pypi/graphviz), which is *another* interface to GraphViz (i.e., its purpose is similar to `pydot`). The executables of GraphViz that Theano calls need to be in the path. This is probably `dot`, but all of them are installed in the same directory, so adding that directory to the path would suffice. – 0 _ Apr 13 '18 at 09:35
  • Thank you for your help again. To be clear, I need to add the directory that holds GraphViz to the path? – Michael Apr 14 '18 at 10:42
  • The directory that contains `dot`, `neato`, and the other executables. – 0 _ Apr 14 '18 at 21:35
0

The error message is giving the clue here: dot.exe is missing in the path (C:/Anaconda/Library/bin). Complementing @Ioannis answer, you have to install GraphViz executables (via conda) for getting the dot.exe in your path.

For my case, after installing GraphViz (conda install GraphViz) I tried with the latest pydot (pip install pydot) and the error was resolved.