【问题标题】:Python 3.4 graphviz issuePython 3.4 graphviz 问题
【发布时间】:2017-07-13 10:10:18
【问题描述】:

我必须在 Jupyter 笔记本上运行以下代码。

from graphviz import Digraph
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)

我必须事先安装 graphviz。在我在 Windows 10 上安装了 graphviz 2.38 之后。我做了“pip install graphviz” 以及“conda install graphviz”。但我得到这个错误

“RuntimeError: failed to execute ['dot', '-Tsvg'], 请确保 Graphviz 可执行文件在您的系统路径上”

我还应该做些什么来消除这个错误?

【问题讨论】:

    标签: python path graphviz


    【解决方案1】:

    您的 python 运行时使用不包含 graphviz 路径的 PATH 环境变量运行。

    您可以通过检查以下(py3)代码来确认这一点:

    import os
    print(os.environ['PATH'])
    

    确实列出了安装 graphviz 的目录。如果没有,请修改您的系统 PATH 环境变量 [1],或在每次运行 python 之前使用以下命令添加到 graphviz 二进制文件的路径:

    set PATH=%PATH%;this_would_be_the_path_to_your_graphiz_binaries_like_dot
    

    [1]https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-03
      • 1970-01-01
      • 2015-03-23
      • 1970-01-01
      相关资源
      最近更新 更多