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

2023-05-16

使用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 pydot
  try:
    import pydotplus as pydot
  except ImportError:
    # Fall back on pydot if necessary.
    try:
      import pydot
    except ImportError:
      pydot = None

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解决:Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work. 的相关文章

随机推荐