欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

OSError:`pydot`failedtocallGraphViz.PleaseinstallGraphVizan

时间:2023-06-03

# 可视化模型结构运行出错

from keras.utils import plot_modelif __name__ == "__main__": model = model.summary() plot_model(model, to_file='model.png', show_shapes=True)

首先:

pip install graphviz

pip install pydot

pip install pydot-ng

下载 graphviz-2.38.msi,存放到C:Program Files (x86)Graphviz2.38  :https://graphviz.gitlab.io/_pages/Download/Download_windows.html

找到安装环境的pydot.py文件,例如D:anaenvstf1.15Libsite-packagespydot.py

pydot.py具体操作:

大概1793行,set_prog函数修改

def set_prog(self, prog): """Sets the default program. Sets the default program in charge of processing the dot file into a graph. """ #self.prog = prog #原方法就该句话 path = r'C:/Program Files (x86)/Graphviz2.38/bin' # 例如我的:F:Program FileAnacondaenvspython3.5Libsite-packagesbin prog = os.path.join(path, prog) prog += '.exe' return prog

大概1845行,create函数添加一句prog = self.set_prog('dot'):

if prog is None: prog = self.prog assert prog is not None prog = self.set_prog('dot') # 此处为添加的语句 if isinstance(prog, (list, tuple)): prog, args = prog[0], prog[1:] else: args = []

再次运行即成功解决问题。

参考:https://blog.csdn.net/weixin_41864878/article/details/81095885

参考:https://blog.csdn.net/weixin_40977054/article/details/104714576

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。