How to Render Graph in Python using graphviz and anytree packages
Asked Answered
B

2

9

I'm following this documentation of anytree package to render the graph. Please note i have install graphviz on my mac using

pip3 install graphviz

When I try to execute this

RenderTreeGraph(udo).to_picture("udo.png")

Im getting following errors

Traceback (most recent call last): File "", line 1, in RenderTreeGraph(udo).to_picture("udo.png") File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/anytree/dotexport.py", line 51, in to_picture check_call(cmd) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 286, in check_call retcode = call(*popenargs, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call with Popen(*popenargs, **kwargs) as p: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in init restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'dot'

please help me render tree

Bumptious answered 3/11, 2017 at 5:29 Comment(0)
J
13

I was getting the same error. I also used pip3 to install graphviz. But when I installed graphviz using following command, it solved my issue.

sudo apt install graphviz
Janitajanith answered 17/3, 2018 at 6:21 Comment(1)
Same. Thanks very much for posting. It's a little disconcerting to me that pip3 install and apt install do different things.Falcongentle
T
2

Please do the following steps:

  1. Determine where graphviz is installed. Typically there is a bin subdirectory. Copy the path to location where the file dot is located. (Just the directory)
  2. Edit your PATH variable and append the path from above. Please ask google how to do this on your machine.

HTH

Tranship answered 19/11, 2017 at 21:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.