1

I get error using the theano.printing.pydotprint() function

following lines work fine without any error:

>>> from theano import *
>>> import theano.tensor as T
>>> import pydot
>>> import numpy

Also when I run

>>> theano.printing.pydotprint

in the python interpreter I get output as

<function pydotprint at 0x307ed70>

but the problem is when I execute the script using the function I get following error

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

Any idea what is the problem?

P.S: I am running the python tutorial given here: http://deeplearning.net/software/theano/tutorial/printing_drawing.html So the call to the function is surely correct.

Here is the traceback of the error I am getting:

---------------------------------------------------------------------------
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.
Abhishek
  • 3,337
  • 4
  • 32
  • 51

2 Answers2

4

Tried reinstalling pydot as given by the solution to this problem, but this was not working.

That is

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

there was some problem with this installation, even though every time, installed successfully message was given.

But

sudo apt-get install python-pydot

this worked.

"Because the solution was not to install pydot from somewhere, but "python-pydot" from official ubuntu repositories." - answer by sadik worked

We must note that on successful installation of pydot, it can be checked at two places.
/usr/share/doc/python-pydot
and
/usr/share/python-support/python-pydot

enter image description here

Community
  • 1
  • 1
Abhishek
  • 3,337
  • 4
  • 32
  • 51
1

Abhishek : Check if you could see the "pydot" folder under the lib folder. Looks like you are in ix machine. Ideally you would find it is installed or not within 'lib' folder / or within site-packages.

Meanwhile, I would suggest you to try re-installing the package(pydot) and see if it helps.

Varun
  • 107
  • 3
  • 10
  • I tried reinstalling pydot along with pyparsing-1.5.7. But this doesn't solve the problem. I dun have pydot folder neither in "/usr/lib" or in "/usr/lib/python2.7/dist-packages". But surprisingly "import pydot" command is working. I have tried reinstallation many times, doesn't help. Any other suggestion? – Abhishek Aug 21 '14 at 11:49
  • 1
    hey got it fixed! The issue was somehow pip was not installing it correctly. The solution was not to install pydot from somewhere, but "python-pydot" from official ubuntu repositories. – Abhishek Aug 21 '14 at 12:30