【发布时间】:2013-04-03 19:45:23
【问题描述】:
当我用 pydot 运行一个非常简单的代码时
import pydot
graph = pydot.Dot(graph_type='graph')
for i in range(3):
edge = pydot.Edge("king", "lord%d" % i)
graph.add_edge(edge)
vassal_num = 0
for i in range(3):
for j in range(2):
edge = pydot.Edge("lord%d" % i, "vassal%d" % vassal_num)
graph.add_edge(edge)
vassal_num += 1
graph.write_png('example1_graph.png')
它会打印出错误信息:
Couldn't import dot_parser, loading of dot files will not be possible.
我正在使用 python 2.7.3
【问题讨论】:
-
pip install pydot2应该可以解决这个问题。比使用pip uninstall好得多,因为如果您共享代码,您只需将 pydot2 添加到您的 requirements.txt 中,而不会让用户运行不熟悉的命令。
标签: python python-2.7 graphviz pydot