AttributeError: 'list' object has no attribute 'write_pdf'
我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf'
我使用的是python3.4
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")
查阅资料后发现,原来我使用的是较新版本的python.可以采取如下两种解决方案:
try with pydotplus:
import pydotplus
...
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf("iris.pdf")
pydot.graph_from_dot_data()returns a list, so try:
graph = pydot.graph_from_dot_data(dot_data.getvalue())
graph[0].write_pdf("iris.pdf")
REF.
AttributeError: 'list' object has no attribute 'write_pdf'的更多相关文章
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- attributeError:'module' object has no attribute ** 解决办法
写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...
- AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'
/*************************************************************************** * AttributeError: 'modu ...
- AttributeError: 'dict_values' object has no attribute 'translate'
/***************************************************************************************** * Attribu ...
- python3 AttributeError: 'NoneType' object has no attribute 'split'
from wsgiref.simple_server import make_server def RunServer(environ, start_response): start_response ...
- 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法
版权声明:本文为博主原创文章,未经博主允许不得转载. 环境flask-script2.0.5.flask0.10.1 运行官方文档sample 出现问题 c:\kk\flask\examples\fl ...
- AttributeError: 'module' object has no attribute 'Thread'
$ python thread.py starting at: 2015-08-05 00:24:24Traceback (most recent call last): File "th ...
- 解决window7 x64位Anaconda启动报错:AttributeError: '_NamespacePath' object has no attribute 'sort'
最近论文需要用到python做数据分析,python语法简单,但是Windows下安装第三方包恶心的要命,statsmodels用pip死活安装不上,网上查了说包相互依赖windows下的pip不能下 ...
- 关于flask登录视图报错AttributeError: '_AppCtxGlobals' object has no attribute 'user'
在一个小程序中写了一个登录视图函数,代码如下: @app.route('/login',methods = ['GET','POST']) @oid.loginhandler def login(): ...
随机推荐
- (原创)VM中的CentOS6.4中安装CloudStack6.3②
接着VM中的CentOS6.4中安装CloudStack6.3①中文章接着,往下面安装 4.更新 yum 仓库 默认情况下,CentOS的软件源中没有收录最新版本CloudStack,为了能顺利安装, ...
- PHP实现发红包程序
我们先来分析下规律. 设定总金额为10元,有N个人随机领取: N=1 第一个 则红包金额=X元: N=2 第二个 为保证第二个红包可以正常发出,第一个红包金额=0.01至9.99之间的某个随机数. 第 ...
- 原生js tab 栏切换
<div id="box"> <div> <button>按钮1</button> <button>按钮2</bu ...
- 修改PHP上传文件大小限制的方法
感谢分享,原文地址:http://www.cnblogs.com/newsouls/archive/2012/12/27/2835628.html 修改PHP上传文件大小限制的方法1. 一般的文件上传 ...
- SVN与git交互
操作的第一步,就是找到版本库,然后打开,有git的文件夹叫版本库 OrderManagement是版本库 第二步,查看日志,在版本库里内部,空白处右键,选择TortoiseGit--showlo ...
- C#使用quartz.net定时问题
因工作需要需要完成定时查询数据..因此在了解之后完成了一个demo 所需要的dll在该地址下载 http://pan.baidu.com/s/1sjNQLXV 首先引入quartz这个dll... 在 ...
- android studio对于错误拼写/不识别的英文单词,给予波浪提示
使用自己的名字当Tag.却发现有个非常不用好的提示.波浪,我浪个你妹. Typo:In word ‘miyuehu’ less...(Ctrl+F1) spellchecker inspection ...
- 小结MapReduce 程序的流程及设计思路
简单回顾一下,目前系统是WCF三层C/S插件系统.服务器端是WCF程序寄宿在IIS中,其中我的配置设计是长连接,客户端支持多线程,一个volatile的实例对象.客户端用Winform,其中客户端框架 ...
- 第六篇T语言实例开发,多点找色应用
---恢复内容开始--- 多点找色应用 文字,图形特征的获取 多点找色 功能原型 窗口多点找色(窗口句柄,x1,y1,x2,y2,颜色值,色点组,相似度,方向,返回x,返回y) 功能说明 根据指定的多 ...
- XJOI‘s story (不定期连载)
王城双基的力量.... 我也不知道写写这种东西会不会被查大表..尴尬 . 我为什么要写这东西: 为了蛤鸡 为了红太阳 xj 人物列传 2017 1,6 Friday 得到大新闻 机房后面的监 ...