|
使用keras时出现`pydot` failed to call GraphViz的解决
keras模型可视化plot_model
报错内容:
'`pydot` failed to call GraphViz.'
OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.
使用了代码 keras.utils.plot_model(model, "dfy_siamModel.png", show_shapes=True)
必须安装:pip3 install pydot
第一反应是 再安装 pip3 install graphviz 但是问题依旧
根据上面报错提示 去官网下载https://www.graphviz.org/ graphviz-2.38.msi并安装成功
添加环境变量:D:\Program Files (x86)\Graphviz2.38\bin 到系统Path
echo %PATH% 看看是否存在?尝试重启电脑试试
再安装 pip3 install graphviz
pip3 install pydot-ng
重点来了:
修改vis_utils.py文件,该文件在我的电脑上位置为:
D:\ProgramData\Miniconda3\envs\py3_torch_gpu\Lib\site-packages\keras\utils
第11行的import pydot注释掉,添加import pydot_ng as pydot
成功解决啦!模型结构瞬间保存为图片了
Linux的Ubuntu下也会出现这个错误,但是解决很简单:
1、pip3 install pydot
2、sudo apt-get install graphviz
不用添加环境变量 不用改代码 以上两步搞定!
|
|