Tensorflow问题记录 --pydot Failed to import pydot. You must install pydot and graphviz for pydotprint to

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

Tensorflow问题记录 --pydot Failed to import pydot. You must install pydot and graphviz for pydotprint to

使用tf.keras.utils.plot_model(model, to_file="model.png", show_shapes=True, show_layer_names=True)绘制可视化模型时出现了上述错误,查找发现问题的解决方式如下:

下载graphviz

  • 首先在官网下载graphviz,msi文件地址
    1.安装graphviz,安装目录为:E:\Program Files (x86)\Graphviz
    2.配置环境变量: 将graphviz的安装文件下的bin目录添加到环境变量PATH中。E:\Program Files (x86)\Graphviz\bin
    3.验证是否安装成功:cmd下执行 dot -version
    Tensorflow问题记录 --pydot Failed to import pydot. You must install pydot and graphviz for pydotprint to

  • 在环境中安装graphviz
    Tensorflow问题记录 --pydot Failed to import pydot. You must install pydot and graphviz for pydotprint to
    安装好graphviz运行代码,仍然错误。这是因为pydot在python3.6版本以上不适用,因此我们需要卸载pydot,安装pydotplus
    1.pip uninstall pydot
    2.pip install pydotplus

更改keras

当安装好pydot之后需要修改环境中的vis_utils.py文件,将文件中的所有pydot替换为pydotplus

Tensorflow问题记录 --pydot Failed to import pydot. You must install pydot and graphviz for pydotprint to

再次执行tf.keras.utils.plot_model(model, to_file="model.png", show_shapes=True, show_layer_names=True)正确

Tensorflow问题记录 --pydot Failed to import pydot. You must install pydot and graphviz for pydotprint to

上一篇:解决GraphViz's executables not found


下一篇:[pydotplus]stderr follows: Format: "png" not reco...