当前位置: 代码迷 >> 综合 >> 解决:Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
  详细解决方案

解决:Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

热度:92   发布时间:2024-02-09 21:12:34.0

使用keras.utils.plot_model时遇到错误:

Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

出错原因是导入pydot时出错,一般的解决方案是:

1、安装pydot, pip install pydot

2、下载graphviz安装,并将安装目录的bin目录加入到系统环境变量path中。

如果以上方案无效,可以调试追踪plot_model代码(Lib\site-packages\tensorflow_core\python\keras\utils\vis_utils),按照代码的提示安装其他类似包,比如安装pydot_ng,pydotplus

try:# pydot-ng is a fork of pydot that is better maintained.import pydot_ng as pydot
except ImportError:# pydotplus is an improved version of pydottry:import pydotplus as pydotexcept ImportError:# Fall back on pydot if necessary.try:import pydotexcept ImportError:pydot = None

 

 

  相关解决方案