我使用以下graphviz代码来读取市场图形格式(.mtx)。
from graphviz import Source
path = '/path/to/dot_file'
s = Source.from_file(path)
s.view()格式描述为here,我写了这篇内容
4 4 6
2 1
3 1
3 2
4 1
4 2
4 3 然而,我得到了这个错误:
s.view()
File "/home/mahmood/.local/lib/python2.7/site-packages/graphviz/files.py", line 242, in view
quiet=quiet, quiet_view=quiet_view)
File "/home/mahmood/.local/lib/python2.7/site-packages/graphviz/files.py", line 209, in render
quiet=quiet)
File "/home/mahmood/.local/lib/python2.7/site-packages/graphviz/backend.py", line 221, in render
run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet)
File "/home/mahmood/.local/lib/python2.7/site-packages/graphviz/backend.py", line 184, in run
output=out, stderr=err)
graphviz.backend.CalledProcessError: Command '['dot', '-Tpdf', '-O', 'graph.mtx']' returned non-zero exit status 1 [stderr: "Error: graph.mtx: syntax error in line 1 near '4'\n"]假设graphviz支持.mtx格式。那我怎么解决这个问题呢?我应该指定更多的选项吗?
发布于 2020-06-07 22:30:18
graphviz不支持直接读取市场矩阵图形文件。Source文档不包括对MTX文件的直接读取的引用,dot程序的命令行文档也不包括(由您的代码/应用编程接口暗中使用)。
Linux2.40.1版上的graphviz库和工具安装确实包含一个名为mm2gv的程序,该程序可将MTX文件转换为dot语言。我没有看到任何通过Python调用此工具的引用,所以我想您最好的选择是将此工具作为一个子流程手动调用。您甚至可以将其输出通过管道传输到正在构建的Source对象。
https://stackoverflow.com/questions/62246038
复制相似问题