首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用python pydot时出错

使用python pydot时出错
EN

Stack Overflow用户
提问于 2014-08-21 09:28:59
回答 2查看 6.2K关注 0票数 1

使用theano.printing.pydotprint()函数时出错

以下几行工作正常,没有任何错误:

代码语言:javascript
复制
>>> from theano import *
>>> import theano.tensor as T
>>> import pydot
>>> import numpy

当我跑的时候

代码语言:javascript
复制
>>> theano.printing.pydotprint

在python解释器中,我的输出为

代码语言:javascript
复制
<function pydotprint at 0x307ed70>

但问题是,当我使用函数执行脚本时,我会得到以下错误

代码语言:javascript
复制
RuntimeError: Failed to import pydot. You must install pydot for `pydotprint` to work.

知道有什么问题吗?

P.S:我正在运行这里给出的python教程:drawing.html,所以对函数的调用肯定是正确的。

下面是我所得到的错误的跟踪:

代码语言:javascript
复制
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    173             else:
    174                 filename = fname
--> 175             __builtin__.execfile(filename, *where)

/home/abhishek/Desktop/Theano/test2.py in <module>()
     64 if not os.path.exists('pics'):
     65     os.mkdir('pics')
---> 66 theano.printing.pydotprint(predict,outfile="pics/logreg_pydotprint_predic.png",var_with_name_simple=True)
     67 # before compilation

     68 theano.printing.pydotprint_variables(prediction,outfile="pics/logreg_pydotprint_prediction.png",var_with_name_simple=True)

/usr/local/lib/python2.7/dist-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)
    566 
    567     if not pydot_imported:
--> 568         raise RuntimeError("Failed to import pydot. You must install pydot"
    569                             " for `pydotprint` to work.")
    570         return

RuntimeError: Failed to import pydot. You must install pydot for `pydotprint` to work.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-08-21 12:21:16

尝试重新安装由solution to this problem提供的pydot,但这是行不通的。

那是

代码语言:javascript
复制
pip uninstall pyparsing
pip install -Iv https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz#md5=9be0fcdcc595199c646ab317c1d9a709
pip install pydot

这个安装有一些问题,即使每次成功安装都会给出消息。

代码语言:javascript
复制
sudo apt-get install python-pydot

这个成功了。

因为解决方案不是从某个地方安装pydot,而是从正式的ubuntu存储库安装python。- answer by sadik起作用了。

我们必须注意,成功安装pydot后,可以在两个地方进行检查。

/usr/share/doc/python-pydot

/usr/share/python-support/python-pydot

票数 4
EN

Stack Overflow用户

发布于 2014-08-21 11:16:27

检查是否可以看到lib文件夹下的"pydot“文件夹。看上去你在九号机里。理想情况下,您会发现它是否安装在'lib‘文件夹/或站点包中。

同时,我建议你尝试重新安装软件包(Pydot),看看它是否有帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25422826

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档