13

When I run import theano in Python, I get the following error message:

Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/theano/__init__.py", line 74, in <module>
    from theano.printing import pprint, pp
  File "/usr/local/lib/python2.7/dist-packages/theano/printing.py", line 35, in <module>
    if pd.find_graphviz():
AttributeError: 'module' object has no attribute 'find_graphviz'

What could be the issue, and how to fix it?

I use Theano 0.8.2 on Ubuntu 14.04.4 LTS x64 with Python 2.7.6 x64.


I unsuccessfully tried:

  • sudo apt-get install -y graphviz libgraphviz-dev
Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501

4 Answers4

21

In pydot 1.2.x version,find_graphviz function have been deprecated. To fix this issue, you should install pydot 1.1.0 version here https://github.com/erocarrera/pydot/tree/v1.1.0 . And it is work for me. May help.

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
Tracholar Zuo
  • 467
  • 2
  • 8
  • 1
    Thanks, I see that some people [recommend](https://github.com/Theano/Theano/commit/8d4e0fd0053496ccfed002ea2898a09627443e4e) `pydot-ng` – Franck Dernoncourt Jul 19 '16 at 14:14
  • 8
    If you need an older version of a python package like pydot, just specify it during install or in your `requirements.txt`, like this: `pip install pydot==1.1.0` – hobs Sep 19 '16 at 21:31
  • @hobs I am unable to install pydot 1.1.0 version. Any idea to resolve this issue - Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-yfv0rpvl/pydot/ – joel Jul 27 '20 at 11:17
  • @joel this sounds like a new question. I'm sure someone on the wider community can help you with that better than I could, if you asked it as a top level question. – hobs Jul 30 '20 at 20:32
11

I solved by installing pydot-ng --> $ pip install pydot-ng

4

For some reason, the Python module pydot was creating the issue:

Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pydot
>>> pydot.find_graphviz()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'find_graphviz'

I was using pydot 1.2.2.

I uninstalled it using sudo pip uninstall -y pydot, and I then was able to successfully import theano.

Bug report: https://github.com/Theano/Theano/issues/4759

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
2

I solved it by using

sudo pip install graphviz
sudo apt-get install graphviz

with the pydot version 1.2.3 works fine

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94
kasim
  • 21
  • 1