python - theano打印pydotprint - 运行时错误:无法导入pydot

时间:2018-04-11 09:27:31

标签: python anaconda theano pydot

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

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

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(最近一次调用最后一次)  in() ----> 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'))

pydotprint中的

〜\ Anaconda3 \ lib \ site-packages \ theano \ printing.py(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为”     782“pydotprint工作。”, - > 783 pydot_imported_msg)     784     785 g = pd.Dot()

RuntimeError :('无法导入pydot。您必须安装graphviz以及pydotprint的pydot或pydot-ng才能正常工作。','导入/尝试pydot时出错:(2,\'“ dot.exe“找不到路径。\”,无,2,无)')

我已经在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位。

提前致谢。

2 个答案:

答案 0 :(得分:0)

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

pydotpluspydot的无保留分支。

答案 1 :(得分:0)

错误消息在此处提供了线索:路径(dot.exe)中缺少C:/Anaconda/Library/bin。为了补充@Ioannis答案,您必须安装GraphViz可执行文件(通过conda),以使dot.exe进入路径。

对于我来说,在安装GraphViz(conda install GraphViz)之后,我尝试使用最新的pydot(pip install pydot),并且错误已解决。