采坑系列(一)——OSError: `pydot` failed to call GraphViz.Please install [GraphViz]

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.

解决: 在此前,下面的操作是必须的

  1. pip install pydot
  2. pip install graphviz
  3. pip install pydot_ng
  4. Windows 安装 graphviz-2.38.msi(1默认安装;2下载地址https://www.graphviz.org/,翻墙下载速度快)
    在这里插入图片描述在这里插入图片描述
  5. 将’C:/Program Files (x86)/Graphviz2.38/bin/'添加进环境的Path
>>>import os
>>>os.environ.get('PATH', '')

就可以查看自己设置的环境变量是不是在列表里面,在的话就说明成功了。

  1. 重启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为本人做的修改,然后重新运行即可。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值