Graphviz's dot tool on Windows
Asked Answered
O

4

13

I've created a Java program to write a .dot file as I'm using the Graphviz software to visualize some data. There is nothing wrong with a code itself, but when I try to execute the following command in command prompt:

dot -Tpdf data.dot -o data.pdf

in a folder where my Java code is located, I get the following error:

'dot' is not recognized as an internal or external command, operable program or batch file.

How can I fix this?

The only similar question I found related to this problem is this one. However, it doesn't seem quite clear to me how could it be helpful in this particular case.

Oxblood answered 13/1, 2018 at 18:55 Comment(0)
N
15

You have to add the directory (folder) where you installed Graphviz to your PATH environment variable. How to do that depends on which version of Windows you have, but for a start, you can look at this answer on Super User.

Notification answered 13/1, 2018 at 19:32 Comment(2)
Thanks for the idea, executing the command "set path=%path%;C:\Program Files (x86)\Graphviz2.38\bin" in a folder where my code is located did the trick.Oxblood
@Oxblood Hi, Where should I run command, and how, please could share how you solved issue, because I am having same issueDrink
T
3

These days you could use Chocolatey: choco install graphviz

That seems to add it to the path as part of the install.

Transmittal answered 1/6, 2021 at 23:14 Comment(1)
choco works much better than pip. It worked right away contrary to pip!Polemic
L
1

Be aware that Graphviz is a folder (container) which contains the "dot" executable. Therefore your modified PATH should lead to dot.py and not just the container Graphviz.

Lenny answered 14/8, 2020 at 8:26 Comment(0)
V
0

I had the same problem, and in my case I could not use any solution that required administrator privileges (e.g., changing environment variables).

So I downloaded the ZIP file from Graphviz and just changed the working directory to the install directory temporarily to call dot or spell out the path to the dot command.

E.g.:

dot -Tpdf data.dot -o data.pdf  &REM Doesn’t work
C:\pathTo\Graphviz\bin\dot -Tpdf data.dot -o data.pdf  &REM Works
Virgievirgil answered 21/7, 2022 at 15:26 Comment(2)
Why is it &REM?Tonettetoney
@PeterMortensen I'm just using an in-line comment for the Window's command-line. Equivalent to Linux echo foo # This line has an `echo` Virgievirgil

© 2022 - 2024 — McMap. All rights reserved.