TheanoGraphs排错

在深度学习教程Theano Graphs部分,按照官网教程运行程序绘制函数图形时,出现如下错误:

  • RuntimeError: Failed to import pydot. You must install pydot for ‘pydotprint’ to work.

见图所示:
TheanoGraphs排错_第1张图片

提示没有安装pydot,退出python命令行,在终端中进行安装(ubuntu 14.04)。
安装pydot之前需要安装c语言版本的graphviz,然后使用pip安装pydotgraphviz。命令为:

  • sudo apt-get install graphviz
  • sudo pip install pydot
  • sudo pip install graphviz

然后进入python命令行中,使用import pydot测试是否安装成功。又出现错误提示:

  • Couldn't import dot_parser, loading of dot files will not be possible.

这是因为pyparsing版本是2.x的,而对应的pydot是1.x,所以出现了版本冲突。
解决办法:安装pydot2,或者卸载目前pyparsing,安装pyparsing 1.x。

  • 安装pydot2
    sudo apt-get install pydot2

  • 降低pyparsing版本

sudo pip uninstall pyparsing
sudo pip install -Iv https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz#md5=9be0fcdcc595199c646ab317c1d9a709

总结

  1. 错误一

    RuntimeError: Failed to import pydot. You must install pydot for ‘pydotprint’ to work.

    解决办法:

    sudo apt-get install graphviz
    sudo pip install pydot
    sudo pip install graphviz
  2. 错误二

    Couldn't import dot_parser, loading of dot files will not be possible.

    解决办法:

    sudo apt-get install pydot2

提示:
在执行
theano.printing.pydotprint(b,outfile="./pics/symbolic_graph_unopt.png",var_with_name_simple=True)
语句之前,当前目录下需要有pics文件夹,否则会报错,提示找不到这个目录。

你可能感兴趣的:(python,ubuntu,深度学习,theano)