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

Model visualization #5313

Closed
AziziShekoofeh opened this issue Feb 7, 2017 · 11 comments
Closed

Model visualization #5313

AziziShekoofeh opened this issue Feb 7, 2017 · 11 comments

Comments

@AziziShekoofeh
Copy link

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

based on the pydot/pydot#126 , It seems it's a Keras problem and maybe Keras need a update in this part.

I can import pydot.find_graphviz, either using pydot_ng or pydot in my own codes but it is generating the error. 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():>

"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 ...."

@ctmakro
Copy link

ctmakro commented Feb 7, 2017

I met this problem before. did you install graphviz? on OSX brew install will work, on Windows download the binary from its homepage.

after installation, you should be able to run dot -h at terminal or cmd. If not, you might need to add it to your PATH.

@AziziShekoofeh
Copy link
Author

Thanks, I have the graphviz installed and I can run dot -h, too.

@johnyf
Copy link
Contributor

johnyf commented Feb 8, 2017

@AziziShekoofeh, thanks for reporting the issue here. In support of the OP, I should note that this is a bug in keras: https://github.com/fchollet/keras/blob/ff1f79603296bffc312076afa0589d229145924c/keras/utils/visualize_util.py#L13.

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, not pydot.

I recommend the following changes to keras:

  1. update the lines referenced above to use pydot == 1.2.3, following this comment: pydot/pydot@812e3c4#commitcomment-18236709, which was implemented in theano
  2. rephrase the error message
  3. remove the dependence on pydot_ng
  4. possibly add 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 (https://github.com/erocarrera/pydot). The comment "pydot-ng is a fork of pydot that is better maintained." is outdated, it was introduced with e5d3abd, so before maintenance of pydot resumed.

@johnyf
Copy link
Contributor

johnyf commented Feb 8, 2017

cf also #3216, which didn't resolve the issue.

@AziziShekoofeh
Copy link
Author

@johnyf Thanks for the thorough explanation.

@ViktorM
Copy link

ViktorM commented Mar 14, 2017

Still have the same error even after installing pydot_ng. OS Windows 10, latest Keras + TF 1.0

@johnyf
Copy link
Contributor

johnyf commented Mar 14, 2017

@ViktorM please see the comments above.

@stale
Copy link

stale bot commented Jun 13, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot closed this as completed Jul 13, 2017
@ftkurt
Copy link

ftkurt commented Dec 5, 2017

Is there any activity on this issue? I am having difficulty addressing the problem. I have graphviz installed on windows (using anaconda) and also able to import following libraries: pydot_ng, pydotplus and pydot

@ganav
Copy link

ganav commented Apr 24, 2018

I have spent all day installing and reinstalling all those pydot(latest version), pydot=1.1.0, pydot-ng....but nothing gave difference...python succesfully imports them but cannot run this line (plot_model(rm.model, to_file=meth + '.png')) and arises error "cannot import pydot please install bla bla.."

@johnyf
Copy link
Contributor

johnyf commented Apr 24, 2018

Have you tried with keras >= 2.1.6?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants