Ubuntu系统下python模块graphviz运行报错:graphviz.backend.execute.ExecutableNotFound: failed to execute PosixPath(‘dot‘)

代码中需要运行python模块graphviz,安装:

pip install graphviz

 

运行后报错:

graphviz.backend.execute.ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH

 

 

报错的全部信息:

Traceback (most recent call last):
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/site-packages/graphviz/backend/execute.py", line 81, in run_check
    proc = subprocess.run(cmd, **kwargs)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot'): PosixPath('dot')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "cartpole.py", line 76, in <module>
    evaluation()
  File "cartpole.py", line 56, in evaluation
    visualize.draw_net(p.config, winner, True, node_names=node_names)
  File "/home/devil/Desktop/neat/visualize.py", line 150, in draw_net
    dot.render(filename, view=view)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/site-packages/graphviz/_tools.py", line 171, in wrapper
    return func(*args, **kwargs)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/site-packages/graphviz/rendering.py", line 122, in render
    rendered = self._render(*args, **kwargs)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/site-packages/graphviz/_tools.py", line 171, in wrapper
    return func(*args, **kwargs)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/site-packages/graphviz/backend/rendering.py", line 327, in render
    capture_output=True)
  File "/home/devil/anaconda3/envs/tmp2/lib/python3.7/site-packages/graphviz/backend/execute.py", line 84, in run_check
    raise ExecutableNotFound(cmd) from e
graphviz.backend.execute.ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH

 

=========================================

 

解决方法:

sudo apt install graphviz

 

 

PS:

原来是没安装绘图的程序,只安装了python的连接模块。

 

 

参考:

https://blog.csdn.net/iLOVEJohnny/article/details/128825005

 

 

 

==========================================

 

posted on 2023-05-13 12:10  Angry_Panda  阅读(1065)  评论(0编辑  收藏  举报

导航