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

后端 未结 12 1183
我在风中等你
我在风中等你 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:21

    The error message is a bit misleading, as you can see here. The problem is that graphviz is not installed.

    But you mention that graphviz was installed using pip. This is also misleading, since that graphviz package is just a python wrapper, and the graphviz binaries have to be installed separately for the python wrapper to work.

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

    For Anaconda on Mac:

    To install this package with conda run:

    conda install -c anaconda graphviz

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

    I had the same problem. I am using Anaconda python on Ubuntu. but it seams that Keras uses system's python not the Anaconda python. Initially, I installed pydot and graphviz using conda. When I installed pydot and graphviz in system's python(using /usr/bin/pip install pydot) it worked fine.

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

    I had similar problem with my Keras (without anaconda). I have solved my problem using this way

    sudo pip install pydot
    sudo pip install graphviz
    sudo add-apt-repository ppa:gviz-adm/graphviz-dev
    sudo apt-get update
    sudo apt-get install graphviz-dev
    
    0 讨论(0)
  • 2020-12-03 05:31

    What I did is followed.

    import keras
    import pydotplus
    from keras.utils.vis_utils import model_to_dot
    keras.utils.vis_utils.pydot = pydot
    
    plot_model(your_model_name, to_file='model.png')
    

    That's worked for me. On mac Anaconda python=3.6.8

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

    Install graphviz by brew in osx brew install graphviz, for ubuntu use apt-get install graphviz, do not need to install graphviz by pip.

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