FileNotFoundError: [WinError 2] "dot" not found in path.和'`pydot` failed to call GraphViz.'问题的解决

在使用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') #调用修改后的函数,新增这行 ```

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值