Python RuntimeError: Failed to import pydot
Question: I am learning concepts of logistic regression concepts. When i implement it in
python, it shows me some error mentioned below. I am beginner in python. Could
anybody help to rectify this error?

RuntimeError Traceback (most recent call last) in ()

    
    
    64 theano.printing.pydotprint(predict,
    65                            outfile="pics/logreg_pydotprint_predic.png",
    66                            var_with_name_simple=True)
    67 # before compilation
    68 theano.printing.pydotprint_variables(prediction,
    

C:\Anaconda\lib\site-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)

    
    
    565 
    566     if not pydot_imported:
    567         raise RuntimeError("Failed to import pydot. You must install pydot"
    568                             " for `pydotprint` to work.")
    569         return
    

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


Answer: I got the same error and I did the following sequence to make it work, in a
Python 3:

    
    
    source activate anaconda
    pip install pydot
    pip install pydotplus
    pip install pydot-ng
    

Then you download and install Graphviz from here according to your OS type:
<http://www.graphviz.org/Download..php>

If you are running Python on Anaconda, open Spyder from terminal, not from
Anaconda. Go to terminal and type:

    
    
    spyder
    

Then:

    
    
    import theano
    import theano.tensor as T
    .
    .
    .
    import pydot
    import graphviz
    import pydot_ng as pydot
    

Develop your model and:

    
    
    theano.printing.pydotprint(prediction, outfile="/Volumes/Python/prediction.png", var_with_name_simple=True)
    

You will have a picture like this: [![enter image description
here](http://i.stack.imgur.com/CO8GR.png)](http://i.stack.imgur.com/CO8GR.png)

