Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find find_graphviz() #126

Closed
willgdjones opened this issue Jul 13, 2016 · 12 comments
Closed

Can't find find_graphviz() #126

willgdjones opened this issue Jul 13, 2016 · 12 comments
Labels

Comments

@willgdjones
Copy link

willgdjones commented Jul 13, 2016

Where has find_graphviz() gone? It's needed for for the documentation examples in Keras.

Python 2.7.12 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

import pydot
pydot.find_graphviz()
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'find_graphviz'

@willgdjones willgdjones changed the title Can't find find_graph() Can't find find_graphviz() Jul 13, 2016
@willgdjones
Copy link
Author

keras-team/keras#3216

@johnyf
Copy link
Contributor

johnyf commented Jul 13, 2016

The function pydot.find_graphviz was an internal function that should have been hidden as _find_graphviz. It was removed in bc639e7, and replaced by the standard library's (superior) functionality available in subprocess. It was made obsolete in ed32d4e, among other commits.

The original version of find_graphviz is a security liability, besides other problems. Please see this comment for further information on this.

Thanks for pointing to the keras package issue. As I remarked in keras-team/keras#3216, there is no reason to call pydot.find_graphviz explicitly. Essentially the same error message will be shown to the user if they try to plot, but the desired GraphViz executable is not found in the $PATH.

So, just removing that call to find_graphviz should solve the problem.

@willgdjones
Copy link
Author

Yep fixed. Thanks!

@johnyf
Copy link
Contributor

johnyf commented Jul 14, 2016

Great!

@AziziShekoofeh
Copy link

AziziShekoofeh commented Feb 6, 2017

As you mentioned and I checked the earlier posts too (keras-team/keras#3216), I have tried pydot_ng and different package version of pydot. I can import pydot.find_graphviz, either using pydot_ng or pydot in my own codes but it is generating this error

ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

or the same each time. Apparently it's trying to call:

<try:
    # pydot-ng is a fork of pydot that is better maintained.
    import pydot_ng as pydot
except ImportError:
    # Fall back on pydot if necessary.
    import pydot
if not pydot.find_graphviz():>

@johnyf
Copy link
Contributor

johnyf commented Feb 6, 2017

Thanks for reporting this issue. This appears to be a bug in keras: https://github.com/fchollet/keras/blob/ff1f79603296bffc312076afa0589d229145924c/keras/utils/visualize_util.py#L13.

Firstly, that the line if not pydot.find_graphviz() is reached means that either pydot_ng or pydot was imported. That an ImportError is raised on the next line means that either pydot_ng was succesfully imported, or an older version of pydot. With the current pydot, an AttributeError would have been raised instead by the line if not ....

The ImportError message on this line: https://github.com/fchollet/keras/blob/ff1f79603296bffc312076afa0589d229145924c/keras/utils/visualize_util.py#L14 is inaccurate. By the reasoning above, some pydot variant was successfully imported. What cannot be found is GraphViz.

So, you need to install GraphViz and ensure that dot is in your $PATH. I would recommend opening a pull request to keras that:

  1. updates those lines to use pydot == 1.2.3, following this comment: 812e3c4#commitcomment-18236709, which was implemented in theano
  2. removes the dependence on pydot_ng
  3. possibly adds pydot == 1.2.3 to the install_requires of keras (https://github.com/fchollet/keras/blob/ff1f79603296bffc312076afa0589d229145924c/setup.py#L13).

Also, pydot_ng is unmaintained (last commit in 2015), in favor of upstream (here). The comment "pydot-ng is a fork of pydot that is better maintained." is outdated, it was introduced with keras-team/keras@e5d3abd, so before maintenance of pydot resumed.

@enduringstack
Copy link

try pydotplus

@johnyf
Copy link
Contributor

johnyf commented May 31, 2017

pydotplus is an unmaintained fork of pydot, and bug fixes and some other changes from it have been merged upstream.

@jecs89
Copy link

jecs89 commented Nov 27, 2017

I found a manual solution:
sudo apt-get install graphviz

graph.write('test.dot')
dot -Tps test.dot -o outfile.ps

You can the files here: https://github.com/jecs89/LearningEveryDay/tree/master/GP

@johnyf
Copy link
Contributor

johnyf commented Nov 27, 2017

GraphViz is a dependency of pydot and needs to be installed separately. Using apt to install GraphViz is one possible approach. Installing pydot is a separate item from installing GraphViz.

@jecs89
Copy link

jecs89 commented Nov 27, 2017

I see but I am not using pydot, I am using pydotplus.

@johnyf
Copy link
Contributor

johnyf commented Nov 27, 2017

pydotplus is an unmaintained fork of pydot.

@pydot pydot locked and limited conversation to collaborators Nov 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants