【问题标题】:python - theano printing pydotprint - runtime error: failed to import pydotpython - theano 打印 pydotprint - 运行时错误:导入 pydot 失败
【发布时间】:2018-09-21 02:53:51
【问题描述】:

我正在尝试运行这个脚本 https://github.com/dennybritz/nn-theano/blob/master/nn-theano.ipynb,它使用 theano 实现了一个神经网络。

一切顺利,直到我到达牢房:

theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, outfile='img/nn-theano-forward_prop.png', format='png')
SVG(theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, return_image=True, format='svg'))

然后我得到这个错误:

RuntimeError                              Traceback (most recent call last)
<ipython-input-11-db44e43f05ee> in <module>()
----> 1 theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, outfile='img/nn-theano-forward_prop.png', format='png')
      2 SVG(theano.printing.pydotprint(forward_prop, var_with_name_simple=True, compact=True, return_image=True, format='svg'))

~\Anaconda3\lib\site-packages\theano\printing.py in pydotprint(fct, outfile, compact, format, with_ids, high_contrast, cond_highlight, colorCodes, max_label_size, scan_graphs, var_with_name_simple, print_output_file, return_image) 781 "和 pydot 或 pydot-ng for " 第782章 --> 783 pydot_imported_msg) 784 785 g = pd.Dot()

RuntimeError: ('Failed to import pydot. You must install graphviz and either pydot or pydot-ng for `pydotprint` to work.', 'An error happened while importing/trying pydot: (2, \'"dot.exe" not found in path.\', None, 2, None)')

我已阅读有关 Stack 的其他问题,并尝试通过 https://graphviz.gitlab.io/ 安装 graphviz

我安装了 pydot、pydotplus、graphviz (2.38.0) 和 python-graphviz (0.8.2)。 我正在使用我最近更新的 Anaconda Navigator。 Python 3.6.4 Windows 10 32 位。

【问题讨论】:

    标签: python anaconda theano pydot


    【解决方案1】:

    GraphViz 可执行文件需要位于$PATH 变量中,pydot 才能找到它们。请看:https://stackoverflow.com/a/47209738/1959808

    pydotpluspydot 的未维护分支。

    【讨论】:

    • 感谢您的回答。 GraphViz 与 graphviz 不同吗?我如何找出需要添加到 $PATH 变量的确切内容?
    • GraphViz 绘制图表。我使用大写来强调没有名为graphviz, and also to avoid confusion with the Python package graphviz 的可执行文件,它是GraphViz 的另一个 接口(即其用途类似于pydot)。 Theano 调用的 GraphViz 的可执行文件需要在路径中。这可能是dot,但它们都安装在同一个目录中,因此将该目录添加到路径中就足够了。
    • 再次感谢您的帮助。要清楚,我需要将保存 GraphViz 的目录添加到路径中?
    • 包含dotneato 和其他可执行文件的目录。
    【解决方案2】:

    错误消息在这里给出了线索​​:路径中缺少dot.exe (C:/Anaconda/Library/bin)。作为@Ioannis 答案的补充,您必须安装 GraphViz 可执行文件(通过 conda)才能在您的路径中获取 dot.exe

    就我而言,安装 GraphViz (conda install GraphViz) 后,我尝试使用最新的 pydot (pip install pydot) 并解决了错误。

    【讨论】:

      猜你喜欢
      • 2016-08-21
      • 2018-07-08
      • 2018-05-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-16
      • 2017-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多