8

I'm trying plot my model on the google colab.

 from keras.utils import plot_model
 plot_model(model, to_file="model.png")

and I got this error:

 ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

I've installed pydot-ng and graphviz and I'm still can't get through this error.

today
  • 32,602
  • 8
  • 95
  • 115
Delen Lawson
  • 83
  • 1
  • 1
  • 4
  • Have you tried to import the pydot module from the python shell? If you cannot import from there, probably this means that this is an environment problem – Nikaido Apr 16 '18 at 09:09
  • @Nikaidoh python shell? google colab is something like Jupyter notebook.So, I don't think I can access the python shell. But I can import pydot in the notebook. – Delen Lawson Apr 16 '18 at 09:20
  • It's the same. :) try to import pydot from the notebook. Probably you will not able to import the module from there. Which means that you haven't correctly installed the dependency. – Nikaido Apr 16 '18 at 09:24

1 Answers1

11

To install pydot, run:

!pip install -q pydot

Then, restart your VM to reload keras which should then detect pydot's existence. (Runtime menu -> Restart runtime...)

Bob Smith
  • 36,107
  • 11
  • 98
  • 91