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

运行绘图代码:

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中。

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

(2)pip install pydotplus

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

(注:不用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文件)。

解决‘Failed to import pydot. You must pip install pydot and install graphviz‘
运行代码:
from tensorflow.keras.utils import plot_model
plot_model(model, show_shapes=True)

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

Original: https://blog.csdn.net/qq_44076218/article/details/124440173
Author: 泡沫不是茶香
Title: 解决‘Failed to import pydot. You must pip install pydot and install graphviz‘

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/509486/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球