1. 程式人生 > 其它 >OSError: `pydot` failed to call GraphViz.Please install GraphViz最笨解決方案

OSError: `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.最笨解決方案
忙活了一晚上,想用plot_model畫一下keras裡畫一下模型結構,結果pydot一直報錯。。多次嘗試無果,修改系統路徑也沒有用,最後採用了個笨辦法,暫時解決了這個問題。

在這裡插入圖片描述
首先我們要在pip install pydot 以及下載並安裝完GraphViz之後,在程式碼前加入下面兩行:

import os 
os.
environ["PATH"] += os.pathsep + 'C:\\Program Files\\Graphviz\\bin'

我這裡是將GraphViz安裝到了C盤下,os.pathsep後面接安裝路徑即可。。
GraphViz下載:
連結: https://www.graphviz.org/.
TIPS:環境變數是當找不到位置時去找的預設路徑,加入環境變數後我們可以在任意路徑操作。比如裝在E盤的python,新增到環境變數之後開啟CMD不用轉換路徑即可操作。