CapsNet-Keras: ImportError: Failed to import `pydot`. Please install `pydot`. For example with `pip install pydot`.

from keras.utils import plot_model plot_model(model)

Showing this error. ImportError: Failed to import pydot. Please install pydot. For example with pip install pydot.

  1. I installed –

(base) C:\Users\lohit>pip install pydot Requirement already satisfied: pydot in c:\users\lohit\anaconda3\lib\site-packages (1.2.4) Requirement already satisfied: pyparsing>=2.1.4 in c:\users\lohit\anaconda3\lib\site-packages (from pydot) (2.2.0)

(base) C:\Users\lohit>pip install pydotplus Requirement already satisfied: pydotplus in c:\users\lohit\anaconda3\lib\site-packages (2.0.2) Requirement already satisfied: pyparsing>=2.0.1 in c:\users\lohit\anaconda3\lib\site-packages (from pydotplus) (2.2.0)

(base) C:\Users\lohit>pip install pydot_ng Requirement already satisfied: pydot_ng in c:\users\lohit\anaconda3\lib\site-packages (1.0.0) Requirement already satisfied: pyparsing>=2.0.1 in c:\users\lohit\anaconda3\lib\site-packages (from pydot_ng) (2.2.0)

(base) C:\Users\lohit>pip install graphviz Requirement already satisfied: graphviz in c:\users\lohit\anaconda3\lib\site-packages (0.9)

Still, it’s showing an error? Kindly help me with this issues.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

In addition to pydot and graphviz install pydotplus. This should solve your problem.

Edit: I overlooked that you already installed pydotplus, my bad. Try uninstalling all pydot related modules and graphiviz, then reinstall in the following order:

  1. pydot
  2. pydotplus
  3. graphviz

For me, this has done the trick on both a Linux and Windows machine.

Try this 😃

import keras
import pydot as pyd
from IPython.display import SVG
from keras.utils.vis_utils import model_to_dot

keras.utils.vis_utils.pydot = pyd

#Visualize Model

def visualize_model(model):
  return SVG(model_to_dot(model).create(prog='dot', format='svg'))
#create your model
#then call the function on your model
visualize_model(model)

In addition to pydot and graphviz install pydotplus. This should solve your problem.

Edit: I overlooked that you already installed pydotplus, my bad. Try uninstalling all pydot related modules and graphiviz, then reinstall in the following order:

  1. pydot
  2. pydotplus
  3. graphviz

For me, this has done the trick on both a Linux and Windows machine.

I followed the advice of uninstalling and reinstalling pydot + pydotplus and that successfully solved the issue on my Windows 10 machine using Anaconda 3. conda uninstall pydot conda uninstall pydotplus conda uninstall graphviz then conda install pydot conda install pydotplus Note: installing pydot also installed graphviz

Just like @anouar1991 said.

What I did are followed: import keras import pydotplus from keras.utils.vis_utils import model_to_dot keras.utils.vis_utils.pydot = pydot plot_model(autoencoder, to_file='model.png')

That’s worked for me.

On Ubuntu 16.04, I try with: sudo apt-get install python-pydot and it worked ok.

i m having the same problem but the process of uninstalling and installing all the modules doesn’t work for me plss help prob

without having to restart my notebook I did this

import keras.utils.vis_utils
from importlib import reload
reload(keras.utils.vis_utils)

@jmikedupont2 thanks it worked after a struggle of 1 hr I found this worked for me