The following error will be displayed.

pydotplus.graphviz.InvocationException: Program terminated with status: 1. stderr follows: Format: "png" not recognized. Use one of:

LastUse one of:Nothing was written after that.

Of course, I installed Graphviz on my PC.

What I tried

[Python] File format is not recognized when creating Graphviz file and output error
In the answer to the above question

pip uninstall graphviz
conda install graphviz

I ran, but it didn't improve.
Rather, the first linepip uninstall graphvizBy executing

ModuleNotFoundError: No module named'graphviz'

The disposition that comes out ...

Pydot error: file format "png" not recognized
In the answer to the above question

pip uninstall pydot2
pip install pydot>= 1.2.3.

Was executed, but it did not improve.
In the first place, the first linepip uninstall pydot2At the time ofpydot2I gave up because there was no such thing, and then the second linepip install pydot>= 1.2.3.However, a mysterious file with no extension written as "1.2.3" was created in the current directory.

  • Answer # 1

    #Create a new dot file or update an existing one
    export_graphviz (...)
    # Read the created dot file
    with open (dir_path +'tree.dot') as file:
        dot_graph = file.read ()
    # Throw the read dot file to Graphviz's Source
    graph_source = graphviz.Source (dot_graph)
    graph_source.render (filename = dir_path +'tree', format ='png')

    By doing this, I was able to create a png file.

    Also, as mentioned above, when rendering, you can specify the path you want to save by connecting the directory path to the file name.
    (If not specified, it will be saved in the current directory)

    In addition to the png file, the rendering also creates an object (?) With the same file name.
    In the above case,



    Will be generated.