在使用keras时出现如下错误:
参考网上教程进行了如下操作:
1. pip install pydot
2. pip install graphviz
3. 从GraphViz官网(https://graphviz.gitlab.io/download/)下载安装graphviz-2.3.8.msi,并将其bin文件夹的路径添加到环境变量path中,也就是将D:\Program Files (x86)\Graphviz2.38\bin(我安装在了D盘)添加到path环境变量中。
然后,运行还是出现上述问题。又参考了chutongz大神的博客,修改了pydot.py中的代码,才解决了上述问题。
修改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
为如下样子:
def set_prog(self, prog):
"""Sets the default program.
Sets the default program in charge of processing
the dot file into a graph.
"""
path = r'path/to/your/dot/exe/file'# 例如我的:D:/Program Files (x86)/Graphviz2.38/bin/
prog = os.path.join(path, prog)
prog += '.exe'
#self.prog = prog
return prog
再修改create函数:
if prog is None:
prog = self.prog
assert prog is not None
prog = self.set_prog('dot') #调用修改后的函数,新增这行 ```