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

RuntimeError: Failed to import pydot. #1801

Closed
mattdornfeld opened this Issue Apr 11, 2014 · 43 comments

Comments

Projects
None yet
@mattdornfeld
Copy link

mattdornfeld commented Apr 11, 2014

I just tried running this example http://deeplearning.net/software/theano/tutorial/printing_drawing.html for printing theano graphs from ipython, and I got this error. Anyone possibly know why? If I try accessing theano.printing.pydotprint, it has no trouble finding the attribute.

RuntimeError Traceback (most recent call last)
in ()
70 theano.printing.pydotprint(predict,
71 outfile="pics/logreg_pydotprint_predic.png",
---> 72 var_with_name_simple=True)
73 # before compilation
74 theano.printing.pydotprint_variables(prediction,
/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

@dwf

This comment has been minimized.

Copy link
Member

dwf commented Apr 11, 2014

Does "import pydot" work? If not, you need to install it, and also graphviz.

On Fri, Apr 11, 2014 at 3:44 PM, Matthew Dornfeld
notifications@github.comwrote:

I just tried running this example
http://deeplearning.net/software/theano/tutorial/printing_drawing.htmlfor printing theano graphs from ipython, and I got this error. Anyone
possibly know why?

RuntimeError Traceback (most recent call last)
in ()
70 theano.printing.pydotprint(predict,
71 outfile="pics/logreg_pydotprint_predic.png",
---> 72 var_with_name_simple=True)
73 # before compilation
74 theano.printing.pydotprint_variables(prediction,
/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

Reply to this email directly or view it on GitHubhttps://github.com//issues/1801
.

@mattdornfeld

This comment has been minimized.

Copy link
Author

mattdornfeld commented Apr 11, 2014

Ahhh thanks. I thought it lived inside theano.

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Apr 12, 2014

I'll close this issue and you seam to understand the solution. If you have more questions, ask us.

@nouiz nouiz closed this Apr 12, 2014

@coralzhang

This comment has been minimized.

Copy link

coralzhang commented May 7, 2014

hi, I have the same problem, but I am quite sure that my import pydot works

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented May 7, 2014

I'm not sure what "quite sure". So can you test this:

1 start python
2 run "import pydot"

Do this work? It must work, so you should be sure at 100% that this work
and the only way is to run it:)

On Wed, May 7, 2014 at 1:13 AM, coralzhang notifications@github.com wrote:

hi, I have the same problem, but I am quite sure that my import pydotworks


Reply to this email directly or view it on GitHubhttps://github.com//issues/1801#issuecomment-42390214
.

@coralzhang

This comment has been minimized.

Copy link

coralzhang commented May 7, 2014

Ok, thank you for your correction.
My problem is that I canimport theanoand import pydotwithout warnings.
But when I try to run this code

deeplearning.net/software/theano/tutorial/printing_drawing.html

I got these error:

Traceback (most recent call last):
  File "/Users/xinlianzhang/Downloads/Python/Theano graph.py", line 73, in <module>
    var_with_name_simple=True)
  File "/usr/local/lib/python2.7/site-packages/theano/printing.py", line 568, in pydotprint
    raise RuntimeError("Failed to import pydot. You must install pydot"
RuntimeError: Failed to import pydot. You must install pydot for `pydotprint` to work.

Any thoughts?

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented May 7, 2014

Run this:

import pydot
print pydot.find_graphviz()

Give me the output.

pydot isn't a self contained program. It need a c library called graphviz.
I think you didn't install it. The code above will check that. Check how to
install graphviz in your system.

Fred

On Wed, May 7, 2014 at 9:51 AM, coralzhang notifications@github.com wrote:

Ok, thank you for your correction.
My problem is that I canimport theanoand import pydotwithout warnings.
But when I try to run this code

deeplearning.net/software/theano/tutorial/printing_drawing.html

I got these error:

Traceback (most recent call last):
File "/Users/xinlianzhang/Downloads/Python/Theano graph.py", line 73, in
var_with_name_simple=True)
File "/usr/local/lib/python2.7/site-packages/theano/printing.py", line 568, in pydotprint
raise RuntimeError("Failed to import pydot. You must install pydot"
RuntimeError: Failed to import pydot. You must install pydot for pydotprint to work.

Any thoughts?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1801#issuecomment-42428963
.

@coralzhang

This comment has been minimized.

Copy link

coralzhang commented May 7, 2014

This is strange... In python, I have

>>> print pydot.find_graphviz()
None

But in the terminal I have

localhost:~ xinlianzhang$ pip list
Cython (0.20.1)
graphviz (0.3.1)
matplotlib (1.3.1)
....
@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented May 7, 2014

Here is the web page of that graphviz. This is a python package called
graphviz. Bad choice of name. You need to install the c version of
graphvis. See this web page:

https://pypi.python.org/pypi/graphviz/0.3.3

From the command line, the command "dot" should work. Look into you OS to
know if it provide graphviz. If so, it will be probably the c version.

Fred

On Wed, May 7, 2014 at 10:22 AM, coralzhang notifications@github.comwrote:

This is strange... In python, I have

print pydot.find_graphviz()
None

But in the terminal I have

localhost:~ xinlianzhang$ pip list
Cython (0.20.1)
graphviz (0.3.1)
matplotlib (1.3.1)
....


Reply to this email directly or view it on GitHubhttps://github.com//issues/1801#issuecomment-42432866
.

@coralzhang

This comment has been minimized.

Copy link

coralzhang commented May 7, 2014

I used the code from the page you gave me, dot is working.
Could you please tell me how can i check if I have graphviz in my system? I am using Mac 10.9.

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented May 7, 2014

If the command line "dot" is installed, graphviz (the c version) should be
installed. So it seam you have hit a bug in pydot. Try to contact them or
update pydot. There was a bug in the past, maybe they had fixed it. But I
forgot what this bug was, so it could be unrelated.

Fred

On Wed, May 7, 2014 at 10:54 AM, coralzhang notifications@github.comwrote:

I used the code from the page you gave me, dot is working.
Could you please tell me how can i check if I have graphviz in my system?
I am using Mac 10.9.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1801#issuecomment-42437227
.

@coralzhang

This comment has been minimized.

Copy link

coralzhang commented May 7, 2014

Thank you so much for you help. I will just go ahead and try to install this c version graphviz first and see how it goes with pydot.

@coralzhang

This comment has been minimized.

Copy link

coralzhang commented May 8, 2014

Hey, dear nouiz. I did as you suggested, and my problem is solved. It turns out that the graphviz is just an interface for the tool `Graphviz``. Thank you again for your help!

@nigellegg

This comment has been minimized.

Copy link

nigellegg commented Jun 28, 2014

Thanks for the above - I had the same problem on Ubuntu, reinstalled pydot (pip install pydot) and installed graphviz (sudo apt-get install graphviz) and it is working now.

@qzshadow

This comment has been minimized.

Copy link

qzshadow commented Aug 14, 2014

if you are using IDE like spyder, you should restart the console inside it(such as IPython console or simple terminal) after install python-pydot

@xuzhm

This comment has been minimized.

Copy link

xuzhm commented Sep 8, 2014

I also have faced a similar situation.............

@chrischoy

This comment has been minimized.

Copy link

chrischoy commented Nov 28, 2014

Just to summarize,

  1. install C-version of graphviz using 'sudo apt-get install graphviz' if ubuntu, 'brew install graphviz' if OSX
  2. pip install pydot
    ( if it fails to import pydot in later stage, http://stackoverflow.com/questions/15951748/pydot-and-graphviz-error-couldnt-import-dot-parser-loading-of-dot-files-will)
  3. pip install graphviz

cheers,

@bugkiwi

This comment has been minimized.

Copy link

bugkiwi commented Feb 11, 2015

@chrischoy brew install graphviz fix my problems! Thank you :)

@bugkiwi

This comment has been minimized.

Copy link

bugkiwi commented Feb 11, 2015

@coralzhang
You should install a C-version graphviz,like brew install graphviz on mac;
and after that you can get some graphviz info like

print pydot.find_graphviz()
{'fdp': '/usr/local/bin/fdp', 'twopi': '/usr/local/bin/twopi', 'neato': '/usr/local/bin/neato', 'dot': '/usr/local/bin/dot', 'circo': '/usr/local/bin/circo'}
@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Oct 30, 2015

The python 3 compatible version of pydot is called pydot-ng. Try to install
that one and use Theano development version.
Le 30 oct. 2015 01:26, "uclyyu" notifications@github.com a écrit :

Anyone here using python 3.4.x?

I am having the same issue on Ubuntu 15.04.
Having followed through the instructions above: apt-get install graphviz
and pip3 install pydot.
The pydot installation doesn't work for me, possibly not python 3.x
compatible.

So I switched to pip3 install pydot3k, which gives:

import pydot

print(pydot.find_graph())
{'circo': '/usr/bin/circo',
'dot': '/usr/bin/dot',
'fdp': '/usr/bin/fdp',
'neato': '/usr/bin/neato',
'sfdp': '/usr/bin/sfdp',
'twopi': '/usr/bin/twopi'}

Unfortunately, the same issue mentioned by @coralzhang
https://github.com/coralzhang persists. Any ideas?

Many thanks!


Reply to this email directly or view it on GitHub
#1801 (comment).

@windweller

This comment has been minimized.

Copy link

windweller commented Dec 9, 2015

This is awesome! I was having a similar problem and did not realize to install C package at all.
Thanks @nouiz !!

@lcetinsoy

This comment has been minimized.

Copy link

lcetinsoy commented Jan 25, 2016

Hi !

I just faced the problem because I had pydot but not graphviz (facepalm). I think that the exception
"Failed to import pydot. You must install pydot" is misleading. The exception can be raised for two reasons (cf start of printing.py) :

  • You do not have pydot
  • You have pydot and not graphviz. In this case, you read the exception and try to import pydot but nothing goes wrong since it can be imported without graphviz installed.

Thereforefore, the exception could be clearer with "you must install pydot and graphviz"

Kind regards,
Laurent

@carlthome

This comment has been minimized.

Copy link
Contributor

carlthome commented Mar 18, 2016

Had the same issue with missing graphviz and it took me longer to fix than it should have since I had to look at the Theano source to understand what was wrong. The ImportError is really misleading.

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Mar 18, 2016

In the master of Theano, the error is:

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

What do you suggest we tell? It already tell that graphviz must be there.
If you have better message to add, we can change it.

thanks

On Fri, Mar 18, 2016 at 11:29 AM, Carl Thomé notifications@github.com
wrote:

Had the same issue with missing graphviz and it took me longer to fix than
it should have since I had to look at the Theano source to understand what
was wrong. The ImportError is really misleading.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1801 (comment)

@carlthome

This comment has been minimized.

Copy link
Contributor

carlthome commented Mar 18, 2016

The same clarification could be added here as well:

raise ImportError('Failed to import pydot. Please install pydot!')

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Mar 18, 2016

Good find. Do you want to make a PR and have your name in the history of
git commit of Theano?

Otherwise, I can do it.

On Fri, Mar 18, 2016 at 1:19 PM, Carl Thomé notifications@github.com
wrote:

The same clarification could be added here as well:

raise ImportError('Failed to import pydot. Please install pydot!')


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1801 (comment)

@carlthome

This comment has been minimized.

Copy link
Contributor

carlthome commented Mar 18, 2016

Yey, the epic commit history! I'll do a pr now. 👍

@jskDr

This comment has been minimized.

Copy link

jskDr commented Sep 7, 2016

brew install graphviz
which I did to resolve this issue.

@Robomate

This comment has been minimized.

Copy link

Robomate commented Sep 11, 2016

what is the command for cmd, windows user (win7)?

i tried pip install graphviz, in cmd it is installed, but in spyder I get the result none.

I even installed graphviz for win, but still same problem in spyder result is none
[(http://www.graphviz.org/Download_windows.php)]

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Sep 12, 2016

It seem spyder don't use the same python as the default one for your OS. I don't use spyder, so I can't help more then tell to check which python spyder is using and install it for that python version with pip. Use the pip in the same folder as the python version that spyder use.

@anujgupta82

This comment has been minimized.

Copy link

anujgupta82 commented Oct 18, 2016

I faced this issue.

Did the 3 steps

  1. brew install graphviz
  2. pip install pydot
  3. pip install graphviz

When I do :
import pydot
print pydot.find_graphviz()

I get "AttributeError: 'module' object has no attribute 'find_graphviz"
I tried http://stackoverflow.com/questions/38446771/importing-theano-attributeerror-module-object-has-no-attribute-find-graphvi

Works smoothly !

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Oct 18, 2016

Newer pydot version don't have that attribute anymore.

Use THeano dev version, we accept newer pydot version now.

On Tue, Oct 18, 2016 at 8:24 AM, Anuj Gupta notifications@github.com
wrote:

I seeming to be still facing this issue.

Did the 3 steps

  1. brew install graphviz
  2. pip install pydot
  3. pip install graphviz

When I do :
import pydot
print pydot.find_graphviz()

I get "AttributeError: 'module' object has no attribute 'find_graphviz"
I tried http://stackoverflow.com/questions/38446771/importing-
theano-attributeerror-module-object-has-no-attribute-find-graphvi
but still getting the error
"AttributeError: 'module' object has no attribute 'find_graphviz"


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1801 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AALC-3XPdleh1d8Xvn5dzu8F2D9qMPDWks5q1LqagaJpZM4Bx0ib
.

@luango3110

This comment has been minimized.

Copy link

luango3110 commented Dec 2, 2016

I have similar error when I run
"from keras.utils.visualize_util import plot"

File "C:\Users\Lua\Anaconda2\lib\site-packages\keras-1.1.1-py2.7.egg\keras\utils\visualize_util.py", line 12, in
raise RuntimeError('Failed to import pydot. You must install pydot'

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

I can import pydot, graphviz, and theano.
When I ran "pydot.find_graphviz()":
Traceback (most recent call last):

File "", line 1, in
pydot.find_graphviz()

AttributeError: 'module' object has no attribute 'find_graphviz'

I tried several pydot versions (pydot 1.2.3, pydot-ng, pydot 1.2.2, and pydot 1.1.0), and graphviz versions (0.5.1 by pip install, 2.38.0-2 by anaconda), but nothing worked.
I use anaconda 4.1.1, python 2.7 in win 10 64-bit (the code was ran in spyder).

Thank you in advance.

@linboqiao

This comment has been minimized.

Copy link

linboqiao commented Dec 19, 2016

sudo apt-get install graphviz
pip install graphviz
pip install pydot==1.1.0

It works on Ubuntu 16.04.

@Switpok

This comment has been minimized.

Copy link

Switpok commented Apr 27, 2017

On mac:
pip install pydot-ng and brew install graphviz worked for me :)

  • Thanks!
@mahernadar

This comment has been minimized.

Copy link

mahernadar commented Jul 14, 2017

Hey guys :)

I am on ubuntu 16.04, working with jupyter notebook with keras and Tensorflow backend.

when i install pyplot using "sudo apt-get install pyplot" i get:

"Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package pyplot"

and naturally, when i run " from keras.utils import plot_model
plot_model(model, to_file='model.png')"

inside the notebook, i get the following error:
"ImportError: Failed to import pydot. You must install pydot and graphviz for pydotprint to work."

How do i correctly install the pyplot and graphviz?

Thanks :)

@qihongl qihongl referenced this issue Nov 5, 2017

Closed

pydot issue #7

@hlpassion

This comment has been minimized.

Copy link

hlpassion commented Nov 28, 2017

brew install graphviz
solve my problem. THX everyone

@Oxi84

This comment has been minimized.

Copy link

Oxi84 commented Jan 14, 2018

Btw I still have the same problem ... I am trying to install graphviz on windows, and I did install the windows version of the software (https://graphviz.gitlab.io/_pages/Download/Download_windows.html) but i do not know what to do with the patch in order to make it work.
I get exception when I do:
print pydot.find_graphviz()

Pydot import does work,

@cristinabustos16

This comment has been minimized.

Copy link

cristinabustos16 commented Jan 17, 2018

I was able to solve it like this:

sudo apt-get install graphviz
pip install pydot
pip install graphviz

@Oxi84

This comment has been minimized.

Copy link

Oxi84 commented Jan 17, 2018

On linux it is easy, but for windows it is more dificult.

@nouiz

This comment has been minimized.

Copy link
Member

nouiz commented Jan 29, 2018

I think conda version of pydot or pydot-ng include graphviz.

@muradalqurishee10

This comment has been minimized.

Copy link

muradalqurishee10 commented Mar 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.