2
Pydot錯誤,我嘗試使用下面的代碼從sklearn(http://scikit-learn.org/stable/modules/tree.html):與sklearn決策樹圖
from sklearn.externals.six import StringIO
import pydot
dot_data = StringIO()
tree.export_graphviz(clf, out_file=dot_data)
graph = pydot.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf("iris.pdf")
我已經安裝了pydot==1.0.2
,當我使用IPython的筆記本電腦運行這段代碼,它提供了以下錯誤。
InvocationException Traceback (most recent call last)
<ipython-input-22-18c25f6a061c> in <module>()
4 tree.export_graphviz(clf, out_file=dot_data)
5 graph = pydot.graph_from_dot_data(dot_data.getvalue())
----> 6 graph.write_pdf("iris.pdf")
/Users/aj/anaconda/lib/python2.7/site-packages/pydot.pyc in <lambda>(path, f, prog)
1600 self.__setattr__(
1601 'write_'+frmt,
-> 1602 lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
1603
1604 f = self.__dict__['write_'+frmt]
/Users/aj/anaconda/lib/python2.7/site-packages/pydot.pyc in write(self, path, prog, format)
1694 dot_fd.write(self.to_string())
1695 else:
-> 1696 dot_fd.write(self.create(prog, format))
1697 dot_fd.close()
1698
/Users/aj/anaconda/lib/python2.7/site-packages/pydot.pyc in create(self, prog, format)
1794 raise InvocationException(
1795 'Program terminated with status: %d. stderr follows: %s' % (
-> 1796 status, stderr_output))
1797 elif stderr_output:
1798 print stderr_output
InvocationException: Program terminated with status: 1. stderr follows: Format: "pdf" not recognized. Use one of
不管我改變它的格式,它給出了同樣的錯誤。我在Mac OS X Yosemite上運行這個程序。
任何建議將不勝感激。
在我的情況下安裝XQuartz並沒有改變錯誤。 XQuartz 2.7.7,OS優勝美地。 [Here's](https://gist.github.com/srodriguex/f7833049784904805d44)我的Python庫列表。 – srodriguex 2015-03-20 00:21:19