from graphviz import Digraph
import pydotplus
dot = Digraph(comment='The Round Table')
dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')
dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
print(dot.source)
dot.render('test-output/round-table.gv', view=True)
报错如下:
RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test-output/round-table.gv'], make sure the Graphviz executables are on your systems' path
解决方法如下:
打开网页下载 Graphviz2.38
https://graphviz.gitlab.io/_pages/Download/Download_windows.html
image.png
配置环境:
将路径 C:\Program Files (x86)\Graphviz2.38\bin 添加至环境变量
最后,重启下电脑就OK了!
网友评论