Package | 解决 graphviz.backend.execute.ExecutableNotFound: failed to execute PosixPath(‘dot‘)

.

background

The experimental environment is to use docker container in Ubuntu.
Trying to use torchviz to visualize the calculation graph of the DL model in the container, where torchviz has been installed based on the following instructions.

pip install torchviz

调用torchviz.make_dot可视化,出现报错,具体报错信息如下:

Traceback (most recent call last): File “/opt/conda/lib/python3.8/site-packages/graphviz/backend/execute.py”, line 81, in run_check
proc = subprocess.run(cmd, **kwargs) File “/opt/conda/lib/python3.8/subprocess.py”, line 493, in run
with Popen(*popenargs, **kwargs) as process: File “/opt/conda/lib/python3.8/subprocess.py”, line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds, File “/opt/conda/lib/python3.8/subprocess.py”, line 1704, in
_execute_child
raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: PosixPath(‘dot’)

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

Traceback (most recent call last): File “test.py”, line 715, in
vis_graph() File “test.py”, line 705, in vis_graph
torchviz.make_dot( File “/opt/conda/lib/python3.8/site-packages/graphviz/_tools.py”, line 171, in wrapper
return func(*args, **kwargs) File “/opt/conda/lib/python3.8/site-packages/graphviz/rendering.py”, line 122, in render
rendered = self._render(*args, **kwargs) File “/opt/conda/lib/python3.8/site-packages/graphviz/_tools.py”, line 171, in wrapper
return func(*args, **kwargs) File “/opt/conda/lib/python3.8/site-packages/graphviz/backend/rendering.py”, line 324, in render
execute.run_check(cmd, File “/opt/conda/lib/python3.8/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

.

solution

The error message indicated: "make sure the Graphviz executables are on your systems' PATH", and a search engine found similar problems .

The graphviz toolkit needs to be installed in the environment, the instructions are as follows:

apt-get install graphviz -y

If you can't find graphviz, update the source of apt and install it again:

apt-get update
apt-get install graphviz -y

Then the installation is successful, and the visualization function can be used normally!

Welcome to discuss in the comment area, I wish you a smooth calculation of the graph!

ps The first article of the Year of the Rabbit, Happy New Year everyone! ^ __________________________________________________ ^

.

Guess you like

Origin blog.csdn.net/iLOVEJohnny/article/details/128825005