mingrammer / diagrams

:art: Diagram as Code for prototyping cloud system architectures
https://diagrams.mingrammer.com
MIT License
39.24k stars 2.52k forks source link

Can't execute Example diagram #403

Open augurer opened 3 years ago

augurer commented 3 years ago

I spun up a new Windows Server 2019 Virtual Machine in Microsoft Azure, installed Visual Studio Code, Cmder, Chocolatey, Python 3.9, GraphViz, and Diagrams as described in this project's documentation. When I attempt to execute the Quick Start sample, I get this output:

C:\Source\diagrams λ python diagram.py Traceback (most recent call last): File "C:\Source\diagrams\diagram.py", line 8, in ELB("lb") >> EC2("web") >> RDS("userdb") File "C:\Python39\lib\site-packages\diagrams__init.py", line 149, in exit self.render() File "C:\Python39\lib\site-packages\diagrams\init__.py", line 191, in render self.dot.render(format=self.outformat, view=self.show, quiet=True) File "C:\Python39\lib\site-packages\graphviz\files.py", line 207, in render rendered = backend.render(self._engine, format, filepath, File "C:\Python39\lib\site-packages\graphviz\backend.py", line 206, in render run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet) File "C:\Python39\lib\site-packages\graphviz\backend.py", line 171, in run raise CalledProcessError(proc.returncode, cmd, graphviz.backend.CalledProcessError: Command '['dot', '-Tpng', '-O', 'web_service']' returned non-zero exit status 1. [stderr: b'Format: "png" not recognized. Use one of:\r\n']

I get a file named "web_service" as a result with the following contents:

digraph "Web Service" {
    graph [fontcolor="#2D3436" fontname="Sans-Serif" fontsize=15 label="Web Service" nodesep=0.60 pad=2.0 rankdir=LR ranksep=0.75 splines=ortho]
    node [fixedsize=true fontcolor="#2D3436" fontname="Sans-Serif" fontsize=13 height=1.4 imagescale=true labelloc=b shape=box style=rounded width=1.4]
    edge [color="#7B8894"]
    "4de433d42d5c4333b6f6db0bbf04624b" [label=lb height=1.9 image="C:\Python39\lib\site-packages\resources/aws/network\elastic-load-balancing.png" shape=none]
    a37b7a3624404e64a66c0b6290e04553 [label=web height=1.9 image="C:\Python39\lib\site-packages\resources/aws/compute\ec2.png" shape=none]
    "4de433d42d5c4333b6f6db0bbf04624b" -> a37b7a3624404e64a66c0b6290e04553 [dir=forward fontcolor="#2D3436" fontname="Sans-Serif" fontsize=13]
    e90b568427dc4377b5229900afdd4a13 [label=userdb height=1.9 image="C:\Python39\lib\site-packages\resources/aws/database\rds.png" shape=none]
    a37b7a3624404e64a66c0b6290e04553 -> e90b568427dc4377b5229900afdd4a13 [dir=forward fontcolor="#2D3436" fontname="Sans-Serif" fontsize=13]
}

I cannot open it with an image application. What am I doing wrong?

dmcken commented 3 years ago

The windows version of graphviz seems to require some configuration of the plugins.

If you execute just dot in a command prompt you will likely get the following error:

There is no layout engine support for "dot"
Perhaps "dot -c" needs to be run (with installer's privileges) to register the plugins?

Open an command prompt with admin privileges and execute "dot -c" and you should be good to go.