gpt4 book ai didi

Python 运行时错误 : Failed to import pydot

转载 作者:太空宇宙 更新时间:2023-11-04 10:47:00 26 4
gpt4 key购买 nike

我正在学习逻辑回归概念的概念。当我在 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 正常工作。

最佳答案

我遇到了同样的错误,我按照以下顺序使其在 Python 3 中工作:

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

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

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

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)

你会得到这样一张图片: enter image description here

关于Python 运行时错误 : Failed to import pydot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16683390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com