Keras: “RuntimeError: Failed to import pydot.” after installing graphviz and pydot

后端 未结 12 1182
我在风中等你
我在风中等你 2020-12-03 04:58

I\'m using Anaconda Python 2.7 on windows 10

I was planning on doing Keras visualization so (whilst spyder was open) I opened the Anaconda command prompt and pip ins

相关标签:
12条回答
  • 2020-12-03 05:06

    1)Conda install graphviz
    2)pip install graphviz
    3)pip install pydot
    then:

    import os os.environ["PATH"] += os.pathsep + AppData\\Local\\Continuum\\anaconda3\\envs\\tensorflow\\Library\\bin\\graphviz'

    0 讨论(0)
  • 2020-12-03 05:07

    it is nothing related to pydot or graphviz if you have installed via pip.

    You should go download graphviz brinary and install.

    Don't forget adding the bin folder into your PATH: C:/Program Files (x86)/Graphviz2.38/bin/

    And after that to close and reopen your console.

    0 讨论(0)
  • 2020-12-03 05:08

    Keras 2.0.6 looks for pydot-ng (better maintained) and then if it's not found, falls back on pydot. I resolved this issue by installing pydot-ng from source.

    0 讨论(0)
  • 2020-12-03 05:12

    The below works inside a jupyter notebook runing in a jupyter/tensorflow-notebook docker container.

    !conda install -y graphviz pydotplus
    
    import pydotplus
    import keras.utils
    keras.utils.vis_utils.pydot = pydotplus
    keras.utils.plot_model(your_model_name, to_file='model.png', show_shapes=True)
    

    You need to tell keras to use pydotplus

    0 讨论(0)
  • 2020-12-03 05:15

    If you are using an Anaconda environment, you'd better install pydotplus and graphviz via conda install.

    conda install graphviz
    conda install pydotplus
    

    Note: You'd better update your Keras to the newest version (2.0.9+), it can automatically check and choose which one of pydotplus,pydot-ng,pydot to be used. pydot-ng has been unmaintained for a long time, and it only supports py3.4- and py2.7.

    0 讨论(0)
  • 2020-12-03 05:18
    1. Install graphviz to the system. Download the package from here, or on Mac:

      brew install graphviz
      
    2. Install python pydot-ng and graphviz wrapper.

      pip install pydot-ng graphviz
      conda install -c anaconda pydot-ng #Anaconda user
      
    3. Use pydot-ng in your code

      import pydot_ng as pydot
      
    4. If Keras visualization utils still uses pydot, try to change import pydot to import pydot_ng as pydot in visualize_util.py

    0 讨论(0)
提交回复
热议问题