Search code examples
pythonanacondatheanopydot

python - theano printing pydotprint - runtime error: failed to import pydot


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.


Solution

  • 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.