【问题标题】:Python RuntimeError: Failed to import pydotPython RuntimeError: 无法导入 pydot
【发布时间】:2013-05-17 00:14:57
【问题描述】:

我正在学习逻辑回归概念的概念。当我在 python 中实现它时,它向我显示了下面提到的一些错误。我是python的初学者。有人可以帮忙纠正这个错误吗?

RuntimeError Traceback(最近一次调用最后一次) 在 ()

64 theano.printing.pydotprint(predict,
65                            outfile="pics/logreg_pydotprint_predic.png",
66                            var_with_name_simple=True)
67 # before compilation
68 theano.printing.pydotprint_variables(prediction,

C:\Anaconda\lib\site-packages\theano\printing.pyc 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, assert_nb_all_strings)

565 
566     if not pydot_imported:
567         raise RuntimeError("Failed to import pydot. You must install pydot"
568                             " for `pydotprint` to work.")
569         return

RuntimeError: 无法导入 pydot。您必须安装 pydot 才能使 pydotprint 工作。

【问题讨论】:

  • 你尝试安装 pydot 了吗?

标签: python theano


【解决方案1】:

我遇到了同样的错误,我在 Python 3 中执行了以下序列以使其正常工作:

source activate anaconda
pip install pydot
pip install pydotplus
pip install pydot-ng

然后根据您的操作系统类型从此处下载并安装 Graphviz: http://www.graphviz.org/Download..php

如果您在 Anaconda 上运行 Python,请从终端打开 Spyder,而不是从 Anaconda。转到终端并输入:

spyder

然后:

import theano
import theano.tensor as T
.
.
.
import pydot
import graphviz
import pydot_ng as pydot

开发您的模型并:

theano.printing.pydotprint(prediction, outfile="/Volumes/Python/prediction.png", var_with_name_simple=True)

你会得到这样的图片:

【讨论】:

    【解决方案2】:

    我也有同样的问题。我建议你在 Github Theano 问题论坛上发布这个:

    https://github.com/Theano/Theano/issues?direction=desc&sort=updated&state=open

    在我看来,由于 pydotprint() 函数的这个实例实际上是 Theano 库中打印模块的一部分,所以这不应该是问题(但确实是),因此应该引起注意开发人员以修复它。

    如果不是这样,请纠正我。

    【讨论】:

      【解决方案3】:

      这主要取决于你把 pydot 文件放在哪里。如果您直接从 Python Shell 运行它,那么您应该将它们安装在模块文件夹中,该文件夹最常见的是主 Python 文件夹中的“Lib”文件夹。

      【讨论】:

      • 我是初学者。我无法理解 Lib 文件夹是什么意思。我已经在 python 2.7.3 版本中运行过这个。在 ipython 中做了 ..你能解释一下答案吗
      猜你喜欢
      • 2020-06-10
      • 2019-11-05
      • 2016-08-04
      • 2019-08-20
      • 2016-05-12
      • 2018-04-15
      • 2017-07-21
      • 2013-05-20
      • 2018-07-08
      相关资源
      最近更新 更多