出現GraphViz's executables not found報錯很有可能是環境變量沒添加上或添加錯地方。
安裝pydotplus、graphviz庫后,開始用pydotplus.graph_from_dot_data函數時,出錯提示:“nvocationException: GraphViz's executables not found”
查閱資料后發現,原來我沒有安裝GraphViz’s executables。用pip安裝的Graphviz,但是Graphviz不是一個python tool,仍然需要安裝GraphViz’s executables。
下載GraphViz’s executables的網址:http://www.graphviz.org/
點擊下載(Download),選擇window系統。
配置環境變量,將graphviz安裝目錄下的bin文件夾添加到Path環境變量中。
驗證是否安裝成功,進入windows命令行界面,輸入dot -version,然后按回車,如果顯示graphviz的相關版本信息,則安裝配置成功。
若Python中運行仍然出錯:’ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'iris'], make sure the Graphviz executables are on your systems' PATH‘
此前設置的環境變量不好用,可以用以下方法,查看了環境變量,發現沒有就會追加上。
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'