Python RuntimeError: Failed to import pydot

一曲冷凌霜 提交于 2019-12-02 07:11:12

问题


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.


回答1:


It mainly depends on where you put the pydot files. If you are running it straight from the Python Shell then you should have them installed in the modules folder which is most commonly the "Lib" folder inside the main python folder.




回答2:


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:




回答3:


I also have the same issue. I would suggest you post this in the Github Theano Issues forum:

https://github.com/Theano/Theano/issues?direction=desc&sort=updated&state=open

It seems to me, that since this instance of the pydotprint() function is actually part of the printing module within the Theano library that this should not be an issue (but it is) and hence it should be brought to the attention of the developers in order to fix it.

Please correct me if this is not the case.



来源:https://stackoverflow.com/questions/16683390/python-runtimeerror-failed-to-import-pydot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!