graphviz-2.38.msi下载链接: https://download.csdn.net/download/weixin_41874898/11441701
电脑系统: win10
在keras可视化模型输出,使用下述函数报错
from keras.utils import plot_model
plot_model(model, to_file=‘model.png’)
报错: OSError: pydot
failed to call GraphViz.Please install [GraphViz] and ensure that its executables are in the $PATH.
解决: 在此前,下面的操作是必须的
- pip install pydot
- pip install graphviz
- pip install pydot_ng
- Windows 安装 graphviz-2.38.msi(1默认安装;2下载地址https://www.graphviz.org/,翻墙下载速度快)
- 将’C:/Program Files (x86)/Graphviz2.38/bin/'添加进环境的Path
>>>import os
>>>os.environ.get('PATH', '')
就可以查看自己设置的环境变量是不是在列表里面,在的话就说明成功了。
- 重启IDE,执行下面语句,报错消失,"mode.png"图片保存成功
from keras.utils import plot_model
plot_model(model, to_file=‘model.png’)
7.如果还是不行,尝试修改D:\3.Anaconda3\Lib\site-packages\pydot.py文件:
DEFAULT_PROGRAMS = {
# 'dot',
'dot.exe',
'twopi',
'neato',
'circo',
'fdp',
'sfdp',
}
注释部分为源码,dot.exe为本人做的修改,然后重新运行即可。