XifengGuo / CapsNet-Keras

A Keras implementation of CapsNet in NIPS2017 paper "Dynamic Routing Between Capsules". Now test error = 0.34%.
MIT License
2.47k stars 654 forks source link

ImportError: Failed to import `pydot`. Please install `pydot`. For example with `pip install pydot`. #69

Closed lohitakshy closed 6 years ago

lohitakshy commented 6 years ago

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.

dominikburger commented 6 years ago

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.

XifengGuo commented 6 years ago

@lohitakshy Please refer to https://github.com/XifengGuo/CapsNet-Keras/issues/7

sakshamjn commented 5 years ago

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

anouar1991 commented 5 years ago

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)
Hippyu commented 5 years ago

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.

Elliott-Ruebush commented 5 years ago

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

swun90 commented 5 years ago

In windows system, also install graphviz software. And add the software bin directory to the system's path. And in class Dot(Graph), change self.prog = 'dot' to self.prog = 'dot.exe'

Seems that the package was written for *nix system. So in windows, assign it to be an .exe file.

Tarek98 commented 4 years ago

@swun90 This is what worked for me. Thank you :-)

ghost commented 4 years ago

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

bowalesamuel commented 4 years ago

@Hippyu it worked for me too 😫

DebottamBasu commented 4 years ago

@ghost this works perfectly

ZNHU commented 4 years ago

My system is MAC, and I have the same problem. Here's my solution:

import os os.environ ['KMP_DUPLICATE_LIB_OK'] ='true'

jmikedupont2 commented 4 years ago

without having to restart my notebook I did this

import keras.utils.vis_utils
from importlib import reload
reload(keras.utils.vis_utils)
inspirepassion commented 3 years ago

For those who wants to install pydot in their virtual environment on their Ubuntu machine, I did it by this:

  1. activate your virtual env, e.g., in terminal: conda activate name_of_env
  2. in termnial: python -m pip install pydot

you can check it out typing 'pip list' in terminal

Shanmukh0028 commented 2 years ago

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