简体   繁体   English

Graphviz 在 Windows 上的点工具

[英]Graphviz's dot tool on Windows

I've created a java program to write a .dot file as I'm using Graphviz software to visualize some data.我创建了一个 java 程序来编写一个 .dot 文件,因为我正在使用 Graphviz 软件来可视化一些数据。 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 dot -Tpdf data.dot -o data.pdf

in a folder where my java code is located, I get the following error:在我的 java 代码所在的文件夹中,我收到以下错误:

'dot' is not recognized as an internal or external command, operable program or batch file. 'dot' 不是内部或外部命令、可运行程序或批处理文件。

Sorry if the question was asked before, but 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.抱歉,如果之前有人问过这个问题,但我发现与此问题相关的唯一类似问题是这个问题,但是,我似乎不太清楚在这种特殊情况下它如何有帮助。

Any help would be appreciated.任何帮助,将不胜感激。 Regards.问候。

You have to add the directory (folder) where you installed Graphviz to your PATH environment variable.您必须将安装 Graphviz 的目录(文件夹)添加到PATH环境变量中。 How to do that depends on which version of Windows you have, but for start you can look at this answer on SuperUser .如何做到这一点取决于您拥有的 Windows 版本,但首先您可以在 SuperUser 上查看此答案

Be aware that Graphviz is a folder (container) which contains the "dot" executable.请注意,Graphviz 是一个文件夹(容器),其中包含“dot”可执行文件。 Therefore your modified PATH should lead to dot.py and not just the container Graphviz .因此,您修改后的 PATH 应该导致dot.py而不仅仅是容器Graphviz

These days you could use chocolaty: choco install graphviz这些天你可以使用巧克力: choco install graphviz

That seems to add it to the path as part of the install这似乎将它作为安装的一部分添加到路径中

I had the same problem, and in my case I could not use any solution that required admin privileges (eg, 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.所以我从graphviz下载了zip文件,只是临时将工作目录更改为安装目录以调用dot或拼出dot命令的路径。

Eg:例如:

dot -Tpdf data.dot -o data.pdf  &REM Doesnt work
C:\pathTo\Graphviz\bin\dot -Tpdf data.dot -o data.pdf  &REM Works

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM