1

I need to generate a tree from a dictionary with python AnyTree package.so I have a dictionary like below structure.

data = {'name': 'xyz',
        'children': [{'name': 'node1',
                      'children': [{'name': 'node2'}]}]}

This dictionary can grow as the program executes.issue that I'm facing right now is when i try to export the tree as a png with DotExporter(root).to_picture("data.png") it throws a file not found error like below

    Traceback (most recent call last):File "C:/Users/.../data_modeling.py", line 88, in<module>creating_tree(main)
  File "C:/Users/.../data_modeling.py", line 66, in creating_tree
    DotExporter(root).to_picture("data.png")
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\anytree\exporter\dotexporter.py", line 229, in to_picture
    check_call(cmd)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 323, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 304, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1155, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I have graphviz package installed and i am on python 3.7 with windows. however using DotExporter(root).to_dotfile('root.dot') I can export the tree as a dot file and using an online converter I can convert dot file to an image. but I need to export this as a png from my program.

I have already googled for similar issues and did all the suggestions and solutions there.any help or suggestion would be great,any other tree graphing tool also would be okay.

Abdul Hoque Nuri
  • 1,105
  • 1
  • 9
  • 18
Akalanka
  • 65
  • 1
  • 12
  • Does this answer your question? [Python, not able to graph trees using graphviz with the anytree package](https://stackoverflow.com/questions/51447235/python-not-able-to-graph-trees-using-graphviz-with-the-anytree-package) – Paulloed Apr 17 '20 at 01:34

1 Answers1

0

found a solution..

problem is with the graphviz python package.when you install graphviz with pip,graphviz python wrapper doesn't contain graphviz binary files.

so to solve this you need to manually download graphviz from their website and set it to path or install graphviz using conda.

alternate to this you can use pydot as a png exporter.and you can use dot file to generate a png with pydot.also pydot can be installed with pip.

Akalanka
  • 65
  • 1
  • 12