解决‘Failed to import pydot. You must `pip install pydot` and install graphviz‘

解决‘Failed to import pydot. You must `pip install pydot` and install graphviz‘,第1张

运行绘图代码:

tf.keras.utils.plot_model(resnet50)

报错:
('Failed to import pydot. You must pip install pydot and install graphviz (https://graphviz.gitlab.io/download/), ', ‘for pydotprint to work.’)

错误尝试1:
pip install pydot
pip install graphviz
安装graphviz-install-2.44.1-win64并添加到用户环境中的path中。
依旧报错…

错误尝试2:
pip install pydot_ng
pip install graphviz
安装graphviz-install-2.44.1-win64并添加到用户环境中的path中。

…错误尝试N次得到的最终方案:不知道怎么一番 *** 作怎么就成了(一下午抓耳挠腮差点放弃)
(1)下载graphviz-install-2.44.1-win64并添加到系统环境中的path中。

(2)pip install pydotplus

(注:不用pip install pydot,因为pydot已经停止开发了)

(3)pip install graphviz
先在官网下载,然后安装之后配置环境变量,再在虚拟环境中用pip安装

(4)找到vis_utils.py把pydot 全部替换成pydotplus
在anaconda文件夹下的Lib/set-packages/keras文件中的vis_utils.py中把所有的pydot替换成pydotplus(根据每个人的文件夹情况找vis_utils.py,比如我的就在D:\anaconda\anaconda_setup\envs\tensorflow\Lib\site-packages\keras\utils文件夹下)(实在找不到可以在电脑中搜索vis_utils.py文件)。

运行代码:

from tensorflow.keras.utils import plot_model
plot_model(model, show_shapes=True)

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/741498.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-28
下一篇2022-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存