1. 程式人生 > >TroubleShooting:OSError: pydot failed to call GraphViz.Please install GraphViz......

TroubleShooting:OSError: pydot failed to call GraphViz.Please install GraphViz......

最近在使用Keras搭建CNN時使用到一個函式plot_model(),這個函式需要使用SVG將網路結構以.png的格式儲存,但是在執行時出現錯誤提示:OSError: pydot failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.

解決步驟:

(1)安裝graphviz-2.38.msi

GraphViz是.msi格式的,在下載的過程中有很多坑,在graphviz.org官網中download時各種報404,在百度搜索時大部分下載不了,最坑的是CSDN上的資源都需要積分,在此還是將我找到的百度雲盤的連結貼在這裡:

https://pan.baidu.com/s/1MHOuCyNRYLFlpIuJfCv7ew,密碼:g2cv  ,graphviz-2.38.msi的安裝方式很簡單:雙擊後,逐步選擇‘next’,在選擇安裝路徑的時候推薦安裝到D盤。

(2)新增環境變數

安裝好之後,需要在windows的系統變數中新增Path中。首先複製graphviz目錄下bin資料夾的地址,如:D:\Program Files (x86)\Graphviz2.38\bin,然後‘’我的電腦‘’->右鍵->屬性->高階系統設定->環境變數->編輯

(3)驗證

安裝完成後,在cmd中輸入dot -version檢視一下,是否安裝成功。然後再次執行Keras的model。

def HappyModel(input_shape):
    X_input = Input(input_shape)
    X = ZeroPadding2D((3, 3))(X_input)
    X = Conv2D(32, (7, 7), strides = (1, 1), name = 'conv0')(X)
    X = BatchNormalization(axis = 3, name = 'bn0')(X)
    X = Activation('relu')(X)

    X = MaxPooling2D((2, 2), name = 'max_pool')(X)

    X = Flatten()(X)
    X = Dense(1, activation = 'sigmoid', name = 'fc')(X)

    model = Model(inputs = X_input, outputs = X, name='HappyModel')
    

    return model

happyModel = HappyModel(X_train.shape[1:])
happyModel.compile(optimizer = 'Adam', loss = 'binary_crossentropy', metrics = ["accuracy"])
happyModel.fit(x = X_train, y = Y_train, epochs = 10, batch_size = 32)

happyModel.summary()
print("done summary")
plot_model(happyModel, to_file='HappyModel.png', show_shapes=True)
SVG(model_to_dot(happyModel).create(prog='dot', format='svg'))

可見已經可以正常執行graphviz了。

Tips:如果在正確的進行前兩部的配置仍然報錯,那就非常有必要使出百試百靈的必殺技:重啟電腦! 

相關推薦

TroubleShooting:OSError: pydot failed to call GraphViz.Please install GraphViz......

最近在使用Keras搭建CNN時使用到一個函式plot_model(),這個函式需要使用SVG將網路結構以.png的格式儲存,但是在執行時出現錯誤提示:OSError: pydot failed to call GraphViz.Please install GraphViz

Ubuntu OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.

安裝pydot,pip install pydot 出現OSError: pydot failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are

Ubuntu pydot failed to call GraphViz.Please install GraphViz 解決方法

如果遇到: OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.

python使用plot_model繪製模型圖(解決報錯`pydot` failed to call GraphViz.Please install GraphViz (https://www.gr)

使用plot_model得先安裝好另外兩個庫,graphviz和pydot pip install graphviz pip install pydot #使用graphviz進行模型的視覺化 import os from keras.utils.vis_utils

keras繪圖之pydotgraphviz的匯入( pydot` failed to call GraphViz

花了很長時間解了一個坑。 救同坑者半條命吧。   ■ 問題現象 在windows系統下,在keras裡面plot_model繪圖時,如果沒有匯入過pydot和graphviz。 在執行時會報告"Failed to import pydot. You must install py

MAC使用IntelliJ IDEA報錯“Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA”

關於該問題,我搜索了絕大多數大家都翻過的解答貼,做一下總結 首先,同樣的報錯可能有很多種原因,絕對是這樣,環境問題、配置問題都有可能,所以不要急,回憶一下出現這個問題的前後有什麼差異化的操作,極有可能就是導致問題的原因 先彙總下目前整理的出現這種報錯的情況,大家可以先看下

IDEA報錯:Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA

     今天小鹹兒開啟Idea的時候,總是報錯:Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA。     經過排查和在網上查詢解決方法之後才知

(Win10/Linux)IDEA:Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA

問題 win 10 電腦藍屏,重啟之後,開啟IDEA出現了Unable to save settings: Failed to save settings. Please restart Int

plot_model 報錯 "Failed to import pydot. You must install pydot and graphviz for 'pydotprint' to work"

plot_model 是 keras 中自帶的一個視覺化工具,可以將網路結構生成如下圖所示的圖片。 使用: from keras.utils import plot_model plot_model(model,to_file='model.png') 但是有時會報錯:

Error: Failed to launch instance "win7": Please try again later [Error: No valid host was found. ].

虛擬機 遇見 enable opensta 錯誤信息 zone roman 博客 win7 感謝朋友支持本博客,歡迎共同探討交流。因為能力和時間有限,錯誤之處在所難免,歡迎指正! 假設轉載,請保留作者信息。 博客地址:http://blog.csdn.net/qq_2

Failed to import pydot

for size work art python環境 參考 import imp rtu 在使用keras進行模型繪制的時候,出現了一個錯誤 Failed to import pydot. You must install pydot and graphviz for `p

Elasticsearch System Call Filters Failed to Install

isa arc cnblogs search disable con ror als blog Elasticsearch starts to run, error occurs: : system call filters failed to install; ch

CentOS5/6/7系統下搭建安裝Amabari大資料叢集時出現SSLError: Failed to connect. Please check openssl library versions.錯誤的解決辦法(圖文詳解)

        不多說,直接上乾貨!         ========================== Creating target directory... ======================

CentOS5/6/7系統下搭建安裝Amabari大數據集群時出現SSLError: Failed to connect. Please check openssl library versions.錯誤的解決辦法(圖文詳解)

詳解 warning 個人博客 xxx pin fig scp oca str   不多說,直接上幹貨! ========================== Creating target directory...

ambari安裝問題 Confirm Hosts SSLError: Failed to connect. Please check openssl library versions

    Running setup agent script... ========================== Command start time 2018-07-20 16:39:31 ("INFO 2018-07-20 16:40:22,452 He

ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on yo

問題發生 在使用xgboost自帶功能繪圖的時候出現了問題 ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems

[bug] ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are

when calling sklearn.tree.export.export_graphviz() I encountered this error: ------------------------

Failed to import 'pydot''的解決辦法

'Failed to import 'pydot''的解決辦法問題解決辦法 問題 準備plot出圖,但是報錯‘Failed to import 'pydot’ from keras.utils import plot_model plot_model(mode

RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test'], make sure the Graphviz executables

在python中想用graphviz畫圖的時候,發現報瞭如下異常: RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test'], make sure the Graphviz executables are on yo

解決CentOS 7出現Failed to issue method call: Unit iptables.service failed to load: No such file or direc

一直用CentOS 6 習慣了,一下沒適應過來。防火牆配置後執行service iptables save 出現"Failed to restart iptables.service: Unit iptables.se