keras: AttributeError: module 'pydot' has no attribute 'find_graphviz'
My os is Ubuntu 14.04 and python version is 3.5. I just simply did what the document said:
from keras.utils.visualize_util import plot
And what I got is:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-90-65016ddab3cd> in <module>()
----> 1 from keras.utils.visualize_util import plot
/home/lcc/anaconda3/envs/sensequant/lib/python3.5/site-packages/keras/utils/visualize_util.py in <module>()
5 # fall back on pydot if necessary
6 import pydot
----> 7 if not pydot.find_graphviz():
8 raise RuntimeError('Failed to import pydot. You must install pydot'
9 ' and graphviz for `pydotprint` to work.')
AttributeError: module 'pydot' has no attribute 'find_graphviz'
Indeed I have ensured that pydot
, pydotplus
, graphviz
have been installed as I could import them properly. Do you know how to fix it? Thank you in advance!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 16
- Comments: 35 (6 by maintainers)
pydot-ng will give you pydot that satisfies the keras package, use
pip install pydot-ng
to install it in your virtualenv.On ubuntu you need to have the “dot” executable in your PATH, you can do this by installing the graphviz package:
apt-get install graphviz
You can try to install
pydot-ng
.I faced similar problem and executing the following commands solved my problem.
On Mac: If you are working in a virtual environment with Anaconda (always do that to avoid messing up the python in your OS):
And run your script from terminal. As a sanity check (in terminal):
The output should be a string similar to: “{‘dot’: ‘your_path/bin/dot’, ‘twopi’: …”
But, @sookinoby is right, model.summary() is much more useful.
Here is how I fix the problem:
sudo pip install pydot==1.0.2 --upgrade
It seems pydot don’t provide a function named find_graphviz anymore.http://stackoverflow.com/questions/36869258/how-to-use-graphviz-with-anaconda-spyder
Downloading Graphviz from their website (msi version in my case given I’m on windows) and adding
C:\Program Files (x86)\Graphviz2.38\bin
to my system variables in PATH worked for me.on Mac, the following commands fixed the issue:
@tboquet Thanks for your help! But this time I got this error:
RuntimeError: Failed to import pydot. You must install pydot and graphviz for
pydotprintto work.
But I have installedpydot
andgraphviz
already. Do you have any idea about that?@oeway The same error still exists…
I have this issue with python3 on ubuntu 16.04. Since I know I have the necessary packages installed, I do the following to avoid the error:
I have this issue with ubuntu 16.04 But raises import error:
This can help me
Thanks @Tahsin-Mayeesha . This is the right solution.
First, the
pydot
willfind_graphviz
, in line 7 ofvisualize_util.py
. Then, it will check these PATH to judge whether thegraphviz
exists, in line 605 ofpydot_ng/__init__.py
.So, we should install
graphviz
by these way:/Applications/Graphviz.app/Contents/MacOS/
;brew install graphviz
, this will create the link to/usr/local/bin
.no not stale unless a human says so
For window, this because python can’t find graphviz path, in pydot_ng init.py It just search path for linux and Mac user, will can fix this problem by add path
We should modify to
http://blog.csdn.net/u014376030/article/details/69945238
try pydotplus
Same issue here… Seems that pydot-ng supports up to Python 3.4? And pydot 1.1.0 not available in conda… For Keras to work properly with Python 3.5, any consideration to embed pydotplus?
pydot pre 1.2.0 do not support python 3…
Could you try to install from here: https://github.com/nlhepler/pydot
As you can see from here https://github.com/nlhepler/pydot/blob/master/pydot/__init__.py#L474 , they do have find_graphviz function.