關於Failed to import pydot. You must install pydot and graphviz for pydotprint
to work的處理建議
環境
win 10
python 3.x
Tensorflow 2.x.x;
pydot 2.4.2
graphviz 2.3.7 ,在graphviz官網上下載適用版本的.msi 安裝包,安裝完畢將bin加到環境變量 path(D:\Program Files (x86)\Graphviz2.37\bin)
報錯代碼:
keras.utils.plot_model(model, 'small_resnet_model.png', show_shapes=True)
報錯信息:
File "D:\Anaconda3_64\envs\tf_gpu\lib\site-packages\tensorflow_core\python\keras\utils\vis_utils.py", line 110, in model_to_dot
raise ImportError('Failed to import pydot. You must install pydot'
ImportError: Failed to import pydot. You must install pydot and graphviz for pydotprint
to work.
原因:
find_graphviz()函數在1.2.x+的pydot版本中已經被棄用了,因此,應該要安裝pydot_ng
解決辦法:
pip install pydot_ng
再次執行,問題解決