首页 > 解决方案 > Graphviz 命令 '['dot', '-Tdot']' 返回非零退出状态 -11

问题描述

我想提取 Graphviz 为我的图表计算的坐标。但是,我在 Python 2.7 和 Graphviz 0.9 中遇到了以下错误:

Graphviz command '['dot', '-Tdot']' returned non-zero exit status -11

我找不到有关这些错误代码的任何文档。下面是我正在使用的代码:

gvz = GraphUtils.toGraphvizGraph(graph)
parsed_dot = gvz.pipe('dot')

第一行将我自己的图形表示转换为 Graphviz Digraph 实例。

result = Digraph()

# By hashing the ids, we get rid of any potential special characters graphviz does not like
# A graphviz ID always needs to start with a character
for node in graph.nodes.to_dict(orient='records'):
    result.node('id_{}'.format(abs(hash(node[node_name_key]))), 'label for width')
# END LOOP

for edge in graph.edges.to_dict(orient='records'):
    result.edge('id_{}'.format(abs(hash(edge[edge_source_key]))), 'id_{}'.format(abs(hash(edge[edge_target_key])), edge[edge_label_key]))
# END LOOP
return result

第二行将图形转换为 DOT,其中包含我需要的坐标。但是,这是我的错误发生的地方。

在测试时,我发现有时我的节点 ID 会包含非法字符(定义见此处)。我通过将我所有的 id 转换为哈希来消除这些情况。现在我所有的节点 id 看起来像这样:

['id_7598267142946574759', 'id_2914022568081909736', 'id_2112657658742367456', 'id_2416843868423017323'] 

这消除了我的一些图表的错误,但不是所有图表。由于错误代码仍然相同,我认为这些 id 肯定还是有问题。但是,由于错误代码实际上并未在任何地方定义,我也可能看错了方向。我错过了什么?

标签: pythonpython-2.7graphviz

解决方案


推荐阅读