报错如下:
Traceback (most recent call last):
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\pydot.py", line 1915, in create
working_dir=tmp_dir,
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\pydot.py", line 136, in call_graphviz
**kwargs
File "E:\Anaconda3\envs\tensorflow_GPU\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "E:\Anaconda3\envs\tensorflow_GPU\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\keras\utils\vis_utils.py", line 26, in _check_pydot
pydot.Dot.create(pydot.Dot())
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\pydot.py", line 1922, in create
raise OSError(*args)
FileNotFoundError: [WinError 2] "dot" not found in path.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\51695\.vscode\extensions\ms-python.python-2019.2.5416\pythonFiles\ptvsd_launcher.py", line 45, in
main(ptvsdArgs)
File "c:\Users\51695\.vscode\extensions\ms-python.python-2019.2.5416\pythonFiles\lib\python\ptvsd\__main__.py", line 357, in main
run()
File "c:\Users\51695\.vscode\extensions\ms-python.python-2019.2.5416\pythonFiles\lib\python\ptvsd\__main__.py", line 257, in run_file
runpy.run_path(target, run_name='__main__')
File "E:\Anaconda3\envs\tensorflow_GPU\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "E:\Anaconda3\envs\tensorflow_GPU\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "E:\Anaconda3\envs\tensorflow_GPU\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "e:\Pythonprogram\SRMD_Keras\models\models.py", line 49, in
plot_model(mysrmd_model, to_file='srmd_model.png')
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\keras\utils\vis_utils.py", line 132, in plot_model
dot = model_to_dot(model, show_shapes, show_layer_names, rankdir)
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\keras\utils\vis_utils.py", line 55, in model_to_dot
_check_pydot()
File "E:\Anaconda3\envs\tensorflow_GPU\lib\site-packages\keras\utils\vis_utils.py", line 29, in _check_pydot
'`pydot` failed to call GraphViz.'
OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.
解决办法:
首先确定安装了pydot、pydot_ng和graphviz,
使用pip 或者conda安装 pydot-->pip install pydot
pydot_ng-->pip install pydot_ng
从 https://graphviz.gitlab.io/download/ 下载windows二进制安装版本,安装好之后将graphviz的安装路径添加到环境变量当中去,安装graphviz时最好选择将安装选项选择为“所有人”。
完成以上步骤如果还是报错就把E:\Anaconda3\envs\tensorflow_GPU\Lib\site-packages下的pydot.py中的def get_executable_extension()改成下面的就可以了
if is_windows():
return '.exe' if is_anacoda() else '.bat' 'change'