Setting up pydot for Python 3.5 and Keras, Conda, and Windows 64

In Keras you can use the function keras.utils.visualize_util.plot to create a image of your model. The problem is getting the function to not throw an error that looks like the following:

AttributeError: 'module' object has no attribute 'find_graphviz'

I went through several stackoverflow questions and forums to figure out what to do. This page had the most useful information. I ended up doing the following:

  1. Install graphviz for windows from the graphviz website.
  2. Add the directory bin of Graphviz to your environment variable “PATH”.
  3. Install pydot_ng in conda using the following command:
> pip install git+https://github.com/pydot/pydot-ng.git
  1. Install Graphviz for Python 3.5.
> pip install graphviz

After you have done the previous steps you should see similar output after running the following command:

>>> import pydot_ng as pydot
>>> print(pydot.find_graphviz())
{'neato': 'C:\\Program Files (x86)\\Graphviz2.38\\bin\\neato.exe', 'twopi': 'C:\\Program Files (x86)\\Graphviz2.38\\bin\\twopi.exe', 'sfdp': 'C:\\Program Files (x86)\\Graphviz2.38\
\bin\\sfdp.exe', 'fdp': 'C:\\Program Files (x86)\\Graphviz2.38\\bin\\fdp.exe', 'dot': 'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', 'circo': 'C:\\Program Files (x86)\\Grap
hviz2.38\\bin\\circo.exe'}
>>>

Extra Information

If you look at the code for Keras here. You can see that Keras handles “pydot_ng”, which works with Python 3.5.

Other References