草庐IT

has-dropdown

全部标签

python - Pandas v0.17.0 : AttributeError: 'unicode' object has no attribute 'version'

我在我的linuxsuse13.264位上直接从源代码安装了pandasv0.17.0。我之前使用yast安装了v0.14.1。现在>>>importpandasTraceback(mostrecentcalllast):File"",line1,inFile"/usr/lib64/python2.7/site-packages/pandas-0.17.0-py2.7-linux-x86_64.egg/pandas/__init__.py",line44,infrompandas.core.apiimport*File"/usr/lib64/python2.7/site-package

python - 为什么我会收到 "instance has no attribute ' __getitem_ _' "错误?

代码如下:classBinaryTree:def__init__(self,rootObj):self.key=rootObjself.left=Noneself.right=Noneroot=[self.key,self.left,self.right]defgetRootVal(root):returnroot[0]defsetRootVal(newVal):root[0]=newValdefgetLeftChild(root):returnroot[1]defgetRightChild(root):returnroot[2]definsertLeft(self,newNode):

python - 属性错误 : 'module' object has no attribute 'SFrame'

我正在Coursera上ML类(class),我已经安装了GraphLabCreate和ipythonnotebook。我是ML和python的新手。我得到以下错误,importgraphlabsf=graphlab.SFrame('people-example.csv')AttributeErrorTraceback(mostrecentcalllast)in()---->1sf=graphlab.SFrame('people-example.csv')AttributeError:'module'objecthasnoattribute'SFrame'我该如何修复这个错误?我的pe

python - 属性错误 : 'module' object has no attribute 'xfeatures2d' [Python/OpenCV 2. 4]

这一行:sift=cv2.xfeatures2d.SIFT_create()返回错误:Traceback(mostrecentcalllast):File"C:/Python27/openCVskrypty/GUI/SOLUTION2.py",line11,insift=cv2.xfeatures2d.SIFT_create()AttributeError:'module'objecthasnoattribute'xfeatures2d'我阅读了一些有关此错误的信息,它出现在OpenCV3.0版中。这很奇怪,因为我有2.4.11版本。我检查了dir(cv2),但没有xfeatures2

python - 诅咒返回 AttributeError : 'module' object has no attribute 'initscr'

我正在关注CursesprogrammingHowToonthePythonsite,但我遇到了一个相当奇怪的问题。我的代码目前非常短,实际上没有做任何事情因为这个错误,我无法继续前进。这是我的代码:importcurses#fromcursesimportwrapperstdscr=curses.initscr()curses.noecho()curses.cbreak()stdscr.keypad(True)defmain(stdscr):begin_x=20;begin_y=7height=5;width=40win=curses.newwin(height,width,begi

python 3 : AttributeError: 'module' object has no attribute '__path__' using urllib in terminal

我的代码在PyCharm中运行完美,但我在尝试在终端中打开它时收到错误消息。我的代码有什么问题,或者我哪里出错了?importurllib.requestwithurllib.request.urlopen('http://python.org/')asresponse:html=response.read()print(html)终端输出:λpythonDesktop\url1.pyTraceback(mostrecentcalllast):File"",line2218,in_find_and_load_unlockedAttributeError:'module'objectha

python ,argparse : enable input parameter when another one has been specified

在我的python脚本中,我希望能够在指定了另一个可选参数时使用可选输入参数仅。示例:$pythonmyScript.py--parameter1value1$pythonmyScript.py--parameter1value1--parameter2value2但不是:$pythonmyScript.py--parameter2value2我如何使用argparse做到这一点?谢谢! 最佳答案 使用自定义操作:importargparsefoo_default=NoneclassBarAction(argparse.Action

python - pyspark 错误 : AttributeError: 'SparkSession' object has no attribute 'parallelize'

我在Jupyternotebook上使用pyspark。以下是Spark的设置方式:importfindsparkfindspark.init(spark_home='/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive',python_path='python2.7')importpysparkfrompyspark.sqlimport*sc=pyspark.sql.SparkSession.builder.master("yarn-client").config("spark.executor.memo

python - 属性错误 : 'FreqDist' object has no attribute 'inc'

我是Python和NLTK的初学者。我正在尝试运行教程中的以下代码:fromnltk.corpusimportgutenbergfromnltkimportFreqDistfd=FreqDist()forwordingutenberg.words('austen-sense.txt'):fd.inc(word)如果我运行它,我会收到以下错误:AttributeError:'FreqDist'objecthasnoattribute'inc'知道我做错了什么吗? 最佳答案 你应该这样做:fd[word]+=1但通常FreqDist是这

python - 属性错误 : 'NoneType' object has no attribute 'format'

print("HelloWorld")print("{}World").format(Hello)我正在开发我的第一个“HelloWorld”程序,我可以通过使用print函数和一个简单的字符串文本来让它工作,但是当我尝试使用.format时,它给出了我的错误:AttributeError:'NoneType'objecthasnoattribute'format'这是说我需要为.format初始化一个变量还是我遗漏了什么? 最佳答案 你的括号错了print("HelloWorld")print("{}World".format('