【问题标题】:Graphviz's executables are not found (Python 3.4)未找到 Graphviz 的可执行文件(Python 3.4)
【发布时间】:2015-04-03 10:52:11
【问题描述】:

我在 Windows 7 上运行 Python3.4。我正在尝试将 Python 接口用于 graphviz。这是我打算运行的脚本:

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

现在我确定我已经正确安装了正确的依赖项。我首先尝试设置正确的环境变量。 graphviz 可执行文件位于 C:\Program Files (x86)\Graphviz2.37\bin 所以我去了环境变量部分。那里有两个部分:用户变量和系统变量。在系统变量下我点击 Path 然后点击Edit 并将 ;C:\Program Files (x86)\Graphviz2.37\bin 添加到字符串的末尾并保存。这并没有清除错误。

然后,按照given here的回答,我卸载了pydot(其实我这里用的是pydotplus)重新安装了一遍,还是没有成功。

我已经尝试了几个小时来解决这个问题,整个 PATH 变量的事情只是令人困惑和沮丧。

【问题讨论】:

    标签: python path graphviz pydot


    【解决方案1】:

    在 Windows 上

    首先,我们需要使用pip安装库:

    pip install graphviz
    

    然后,我们可以尝试运行以下命令(根据其他答案的建议):

    conda install graphviz
    

    然而,对我来说,这会导致 HTTP 错误

    参考official documentation后,最终选择了graphviz通过Chocolatey Package Manager安装的路径。

    以管理员模式打开你的 shell,然后运行以下命令:

    choco install graphviz -y
    

    重启内核,问题就解决了。

    【讨论】:

      猜你喜欢
      • 2017-11-05
      • 2016-12-18
      • 2018-07-29
      • 2023-03-06
      • 1970-01-01
      • 2015-02-24
      • 2017-09-18
      • 2021-03-22
      • 2018-01-25
      相关资源
      最近更新 更多