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

解决 plot_model 中ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.的错误

看了好多解决方法都不管用,就连安装然后添加路径都不管用

后来找到原因是pydot已经停止开发了,python3.5和python3.6已经用不起来

 

解决方式

1.  卸载 pydot

pip uninstall pydot

2.  安装 pydotplus

pip install pydotplus

3.  找到  E:\Anaconda\envs\tensorflow\lib\site-packages\keras\utils\vis_utils.py

(在spyder中报错文件路径可以直接点进去)

将文件中的第 6 行

"""Utilities related to model visualization."""
import os

try:
    # pydot-ng is a fork of pydot that is better maintained.
    import pydot as pydot
except ImportError:
    # pydotplus is an improved version of pydot
    try:
        import pydotplus as pydot
    except ImportError:
        # Fall back on pydot if necessary.
        try:
            import pydot
        except ImportError:
            pydot = None

也就是第一个try下的:

import pydot as pydot

更换为:

import pydotplus as pydot

问题解决

你可能感兴趣的:(ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.)