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(): ...
随机推荐
- Mac快捷键与命令学习
最近开始使用mac air,以前从来没有接触过IOS系统,各种操作捉急.Mac快捷键相当多,遇到各种操作不会就只好百度,然后整理了一堆有用或者没用的命令,一股脑儿列在下面.其中有不少命令是和linux ...
- (进阶篇)PHP实现用户注册后邮箱验证,激活帐号
我们在很多网站注册会员时,注册完成后,系统会自动向用户的邮箱发送一封邮件,这封邮件的内容就是一个URL链接,用户需要点击打开这个链接才能激活之前在该网站注册的帐号.激活成功后才能正常使用会员功能. 本 ...
- 转发 通过NAT和防火墙特性和TCP穿透的测评(翻译)
转自 http://blog.csdn.net/sjin_1314/article/details/18178329 原文:Characterization and Measurement of TC ...
- JDBC中连接MySQL数据库
package qddx.JDBC; import java.sql.*; public class JDBC_Connection { static String driverName = &quo ...
- 如何解决 win10连了VPN怎么上外网
当前用户配置%AppData%\Microsoft\Network\Connections\Pbk与所有用户共享配置%ProgramData%\Microsoft\Network\Connection ...
- android中加载的html获取的宽高不正确
wap页面使用 js库是zepto,按照惯例在$(function(){})中,来获取当前可视区的宽高,但得到的宽高却与预想的相差十万八千里. 原本android手机的浏览器设定的宽高基本是360*6 ...
- JDBC的应用实例
首先要添加一个引用的库 在项目上右键--构建路径--配置构建路径--在(库)中选择添加外部JAR--选择jar包添加 jar文件是驱动包 添加后包资源管理器中显示一个引用的库会有jar包 加载数据访问 ...
- POJ1986 Distance Queries (LCA)(倍增)
Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 12950 Accepted: 4577 ...
- HDU2647
第一道逆拓扑纪念一下... #include<iostream> #include<cstdio> #include<cstring> #include<cm ...
- Java注释
注释:用于注解说明解释程序的文字.提高了代码的阅读性. 一:单行注释 "//注释文字" 二:多行注释 "/*注释文字*/" 三:文档格式 "/**注释 ...