windows错误:Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

windows错误:Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

文章目录:

1 用keras对模型进行可视化

由于tensorflow2.0 和keras已经完全兼容了,直接用keras进行查看模型非常方便,然后用构建的模型进行可是化报错

可是化代码:

# tensorflow version 2.0
from tensorflow import keras

keras.utils.plot_model(keras.applications.ResNet50(
                include_top=True,
                input_shape=(224,224,3),
                weights=None), to_file='image_model.png', show_shapes=True)

然后运行报错:

错误:Failed to import pydot. You must install pydot and graphviz for pydotprint to work.

2 错误解决方式

1、在windows下错误的解决方式

这种解决方式在windows下不行,在其他平台下可以

pip install pydot
pip install graphviz

2、在windows下正确的解决方式

1、下载graphviz
在windows下不可以使用pip install graphviz 下载graphviz安装包,要去https://graphviz.gitlab.io/下载windows版本的安装包,安装好之后在环境变量中添加对应的路径即可!!!

2、安装pydotplus

pip install pydotplus

3、添加环境比变量
在这里插入图片描述

4、重启你的terminal或者编辑器
之后在运行正常,效果如下:
在这里插入图片描述

扫描二维码关注公众号,回复: 11321062 查看本文章

在这里插入图片描述


在这里插入图片描述


在这里插入图片描述
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠

猜你喜欢

转载自blog.csdn.net/weixin_41010198/article/details/102689447