草庐IT

has-dropdown

全部标签

python - 属性错误 : 'DataFrame' object has no attribute 'map'

我想使用下面的代码转换Spark数据框来添加:frompyspark.mllib.clusteringimportKMeansspark_df=sqlContext.createDataFrame(pandas_df)rdd=spark_df.map(lambdadata:Vectors.dense([float(c)forcindata]))model=KMeans.train(rdd,2,maxIterations=10,runs=30,initializationMode="random")详细的错误信息是:------------------------------------

python - 属性错误 : 'module' object (scipy) has no attribute 'misc'

我从ubuntu12.04更新到ubuntu12.10并且我编写的python模块突然不再适用于模块scipy没有属性“misc”的错误消息。这以前有效。更新后我仍在使用python2.7。这是代码崩溃的地方importscipyscipy.misc.imsave(slice,dat)有什么想法吗? 最佳答案 >>>importscipy>>>scipy.miscTraceback(mostrecentcalllast):File"",line1,inAttributeError:'module'objecthasnoattribu

python - 从同名脚本导入已安装的包会引发 "AttributeError: module has no attribute"或 "ImportError: cannot import name"

我有一个名为requests.py的脚本,用于导入requests包。该脚本要么无法访问包中的属性,要么无法导入它们。为什么这不起作用,我该如何解决?以下代码引发AttributeError。importrequestsres=requests.get('http://www.google.ca')print(res)Traceback(mostrecentcalllast):File"/Users/me/dev/rough/requests.py",line1,inimportrequestsFile"/Users/me/dev/rough/requests.py",line3,in

python - 避免 Pylint 警告 E1101 : 'Instance of .. has no .. member' for class with dynamic attributes

想象一个函数,它动态地使用setattr向对象添加属性。这样做的原因是我想将一些外部结构(例如给定的参数树)映射到一个对象:my_object=SomeClass()apply_structure(my_object,some_descriptor)my_object.device1.enabled=True从技术上讲,这是可行的,但Pylint当然正确地提示'device1'不是SomeClass的成员。我可以禁用警告,但这会很糟糕(因为在所有情况下,当属性由于拼写错误等原因不存在时,我仍然希望得到警告)。是否有一种常见且合法的(Pylint-proof)方法可以动态地将成员添加到不

python - 属性错误 : module 'html.parser' has no attribute 'HTMLParseError'

这是提示,我该如何解决?我使用Python3.5.1通过virtualenv创建了一个虚拟环境源代码在我friend的电脑上运行良好错误:Traceback(mostrecentcalllast):File"manage.py",line10,inexecute_from_command_line(sys.argv)File"A:\Python3.5\lib\site-packages\django\core\management\__init__.py",line385,inexecute_from_command_lineutility.execute()File"A:\Pytho

python - graph.write_pdf ("iris.pdf") AttributeError : 'list' object has no attribute 'write_pdf'

我的代码是按照google的机器学习类的。两个代码是一样的。我不知道为什么会显示错误。可能是变量的类型是错误的。但是google的代码对我来说是一样的。谁有遇到过这个问题吗?这是错误[012][012]Traceback(mostrecentcalllast):File"/media/joyce/oreo/python/machine_learn/VisualizingADecisionTree.py",line34,ingraph.write_pdf("iris.pdf")AttributeError:'list'objecthasnoattribute'write_pdf'[Fin

python - 属性错误 : Module Pip has no attribute 'main'

我正在尝试为名为Zulip的开源项目构建pythonapi,但我一直遇到与下面的屏幕截图所示相同的问题。我正在运行python3,我的pip版本是10.0.0。有问题的文件是setup.py并且搞砸的代码是访问pip.main()属性以安装包时。现在,我知道这个构建应该会成功,因为它是一个开源项目,但我已经尝试了几个小时来解决关于pip.main()的依赖问题。任何帮助将不胜感激。 最佳答案 python3-mpipinstall--user--upgradepip==9.0.3pipissue:rollback

python - 为什么我收到 AttributeError : Object has no attribute?

已结束。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭2年前。本帖已编辑提交审核去年未能重新打开帖子:原始关闭原因未解决Improvethisquestion我有一个类(class)MyThread。在那,我有一个方法示例。我试图从同一个对象上下文中运行它。请看代码:classmyThread(threading.Thread):def__init__(self,threadID,name,cou

python - 'dict' 对象没有属性 'has_key'

在Python中遍历图形时,我收到此错误:'dict'objecthasnoattribute'has_key'这是我的代码:deffind_path(graph,start,end,path=[]):path=path+[start]ifstart==end:returnpathifnotgraph.has_key(start):returnNonefornodeingraph[start]:ifnodenotinpath:newpath=find_path(graph,node,end,path)ifnewpath:returnnewpathreturnNone代码旨在找到从一个节

Python 属性错误 : 'module' object has no attribute 'SSL_ST_INIT'

我的一个Python脚本失败了:Traceback(mostrecentcalllast):File"./inspect_sheet.py",line21,inmain()File"./inspect_sheet.py",line12,inmainworkbook_name=workbook_name,File"./google_sheets.py",line56,in__init__self.login()File"./google_sheets.py",line46,inloginself.client=gspread.authorize(credentials)File"/usr