The get_highest_row() method has been deprecated, you can get the highest row or column by calling the max_row or max_column properties of the worksheet.

ws=wb.get_sheet_by_name('Sheet1')

print(ws.max_row)
Answer from idemello on Stack Overflow
Discussions

openpyxl - 'NoneType' object has no attribute 'max_row' - Stack Overflow
os whidow7 python3.6 openpyxl 2.5.4 ------------------------------------------------------------------ how to solve this problem? Traceback (most recent call last): File "C:\python\updataProduce... More on stackoverflow.com
🌐 stackoverflow.com
July 5, 2018
openpyxl - Python script having errorr 'NoneType' object has no attribute 'max_row' - Stack Overflow
need some help on the error that I am getting for my python script. I need to fetch the last row number in my excel work sheet. Im using openpyxl==2.5.12. Below is the code and error that I am g... More on stackoverflow.com
🌐 stackoverflow.com
March 22, 2019
python - AttributeError: 'property' object has no attribute - Stack Overflow
Python (2.6) seems to be derping for no reason, can anyone see a problem with this code? class DB (): def doSomething (self, str): print str class A (): __db = DB() @staticme... More on stackoverflow.com
🌐 stackoverflow.com
python 2.7 - Openpyxl AttributeError - Stack Overflow
I was running this file fine yesterday and now I'm getting an AttributeError when I tried running it today. Here is the code I'm trying to run: from openpyxl import load_workbook def r... More on stackoverflow.com
🌐 stackoverflow.com
June 21, 2017
🌐
GitHub
github.com › matplotlib › matplotlib › issues › 12988
AttributeError: 'str' object has no attribute 'max_row' with openpyxl library · Issue #12988 · matplotlib/matplotlib
December 14, 2018 - Actual outcome 19 for i in range(1,santa.max_row): 20 for j in range(1,17): 21 check=str(santa.cell(row=i,column=j).value) AttributeError: 'str' object has no attribute 'max_row'> No one assigned · No labels · No labels · No type · No projects · No milestone ·
Author   Sarthak-Shah
Top answer
1 of 3
22

In addition to needing to inherit from object, properties only work on instances.

a = A()
a.db.doSomething("blah")

To make a property work on the class, you can define a metaclass. (A class is an instance of a metaclass, so properties defined on the metaclass work on the class, just as properties defined on a class work on an instance of that class.)

2 of 3
1

You aren't using classes correctly. A class is (normally) two things:

  1. A factory for creating a family of related objects
  2. A definition of the common behaviour of those objects

These related objects are the instances of the class. Normal methods are invoked on instances of the class, not on the class itself. If you want methods that can be invoked from the class, without an instance, you need to label the methods with @classmethod (or @staticmethod).

However I don't actually know whether properties work when retrieved from a class object. I can't check right now, but I don't think so. The error you are getting is that A.db is retrieving the property object which defines the property itself, it isn't "evaluating" the property to get A.__db. Property objects have no doSomething attribute. Properties are designed to be created in classes as descriptions of how the instances of those classes work.

If you did intend to be working with an instance of A, then you'll need to create one:

my_a = A()
my_a.db.doSomething("blah")

However, this will also fail. You have not correctly written getDB as any kind of method. Normal methods need an argument to represent the instance it was invoked on (traditionally called self):

def getDB(self):
    ...

Static methods don't, but need a decorator to label them as static:

@staticmethod
def getDB():
    ...

Class methods need both an argument to receive the class they were invoked on, and a decorator:

@classmethod
def getDB(cls):
    ...
🌐
Edureka Community
edureka.co › home › community › categories › python › python pandas error attributeerror dataframe ...
Python Pandas error AttributeError DataFrame object has no attribute rows | Edureka Community
March 28, 2019 - I am trying to print each entry of the dataframe separately. The dataframe is created by reading ... : 'DataFrame' object has no attribute 'rows'
🌐
Stack Overflow
stackoverflow.com › questions › 44659877 › openpyxl-attributeerror
python 2.7 - Openpyxl AttributeError - Stack Overflow
June 21, 2017 - Your openpyxl version is seriously outdated - hence the absence of max_row attribute on a WorkSheet class.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
July 23, 2025 - To understand this error, we first have to know how to read the error message effectively. It typically consists of two parts: "AttributeError" and "Object has no attribute." The former indicates the type of error, and the latter suggests that the attribute we are trying to access does not exist for the object.
🌐
GitHub
github.com › sqlalchemy › sqlalchemy › issues › 5532
AttributeError: 'property' object has no attribute 'property' · Issue #5532 · sqlalchemy/sqlalchemy
August 24, 2020 - class CustomBase(object): def instance_method(self): class_ = inspect(self).mapper.class_ class_property = class_.bravo.property print(type(class_property)) Base = declarative_base(cls=CustomBase) class Alpha(Base): bravo = relationship('Bravo') When running Alpha().instance_method(), I'm getting AttributeError: 'property' object has no attribute 'property'.
Author   cuzox
🌐
Reddit
reddit.com › r/python › behavior of attributeerror in @property and __getattr__
r/Python on Reddit: Behavior of AttributeError in @property and __getattr__
April 14, 2024 -

I'm sure that many people have encountered the following (code for reproduction below) behavior: if during the execution of `@property`, an `AttributeError` is raised and the same class implements `__getattr__` then `__getattr__` is invoked with the name of the property resulting in a confusing message: `AttributeError: 'Foo' object has no attribute 'something'`. If we remove `__getattr__` then we get a more meaningful and correct message: `AttributeError: 'Foo' object has no attribute 'bar'`.

from dataclasses import dataclass

@dataclass
class Foo: val = 'foo_value'

class Test: 
    def __init__(self): 
        self.foo = Foo()

    def __getattr__(self, name):
        return getattr(self.foo, name)
    
    @property
    def something(self):
        return self.foo.bar

t = Test() t.something

The error message is misleading and the behavior catches many people (myself including) in surprise and results in many wasted hours of debugging. I've seen people recommend using a custom decorator (instead of `@property` that catches attribute error) or wrapping your `@property` bodies in `try/except`. But it seems to me that this should be dealt with on language level.

I'm trying to understand a few things:

  1. Is this behavior in Python intentional (i.e. is there a good reason) or just stems from the fact that `__getattr__` is invoked when `AttributeError` is raised when an instance attribute is accessed?

  2. If not intentional, is there a relatively easy way to detect `AttributeErrors` cause by `@property` execution in CPython? If so, why hasn't this been handled on language level?

  3. I've searched CPython issues on Github and I saw someone trying to correct documentation but couldn't find issues asking about this behavior or suggestions to fix - am I missing something?

🌐
GitHub
github.com › saulpw › visidata › issues › 797
AttributeError: 'Chartsheet' object has no attribute 'iter_rows' · Issue #797 · saulpw/visidata
November 20, 2020 - Traceback (most recent call last): File "/home/aborruso/.local/lib/python3.8/site-packages/visidata/threads.py", line 215, in _toplevelTryFunc t.status = func(*args, **kwargs) File "/home/aborruso/.local/lib/python3.8/site-packages/visidata/sheets.py", line 884, in reload self.setCols(list(self.optlines(itsource, 'header'))) File "/home/aborruso/.local/lib/python3.8/site-packages/visidata/sheets.py", line 870, in optlines yield next(it) File "/home/aborruso/.local/lib/python3.8/site-packages/visidata/loaders/xlsx.py", line 33, in iterload for row in Progress(worksheet.iter_rows(), total=worksheet.max_row or 0): AttributeError: 'Chartsheet' object has no attribute 'iter_rows'
Author   aborruso
Top answer
1 of 1
1

Having an attribute that equals to "None" is different from not having such attribute at all, if you use:

if row.total_bytes_processed is not None:

Python will try to access this object's attribute called "total_bytes_processed" and then comparing it to None. You're getting this error because in this case, the attribute "total_bytes_processed" does not exists for that object.

You could use the method "hasattr", provide the object and the name of the attribute you're looking for, as parameters, and the method will return True if the parameter exists and False otherwise:

if hasattr(row, "total_bytes_processed"):

Keep in mind that "hasattr" will still return True even if the attribute exists and equals to "None", so you could put it as and outer validation and then, after you know that the attribute exists, verify if it's equal to "None" and act accordingly. It would be something like:

for row in rows:
  if hasattr(row, "total_bytes_processed"):
    if row.total_bytes_processed is not None:
        cost_dollars = (row.total_bytes_processed/1024 **4) *5
        print( f"JOB_ID : {row.job_id} | Creation_Time : {row.creation_time} |  Query: {row.query} | Total_Bytes_processed : {row.total_bytes_processed} | Estimated_Cost : ${cost_dollars}".format(
        row.job_id, row.creation_time, row.query, row.total_bytes_processed,cost_dollars))
    else:
        row.total_bytes_processed = 0
        cost_dollars = (int(row.total_bytes_processed) / 1024 ** 4) * 5
        print(f"JOB_ID : {row.job_id} | Creation_Time : {row.creation_time} |  Query: {row.query} | Total_Bytes_processed : {row.total_bytes_processed} | Estimated_Cost : ${cost_dollars}".format(row.job_id, row.creation_time, row.query, row.total_bytes_processed, cost_dollars))
  else:
    #code for when total_bytes_processed does not exists
🌐
GitHub
github.com › explodinggradients › ragas › issues › 459
AttributeError("'list' object has no attribute 'get'") when calculating metrics score · Issue #459 · vibrantlabsai/ragas
January 13, 2024 - result = evaluate( llm=azure_model, dataset=dataset, # selecting only 3 metrics=[ context_precision, faithfulness, answer_relevancy, context_recall, context_relevancy ], ) Error trace [chain/error] [122:chain:row 120 > 125:chain:answer_relevancy] [6.01s] Chain run errored with error: "AttributeError("'list' object has no attribute 'get'")Traceback (most recent call last):\n\n\n File "C:\Users\allenpan\Anaconda\envs\rag_experiment\Lib\site-packages\ragas\metrics\base.py", line 71, in score\n score = self._score(row=row, callbacks=group_cm)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n File "
Author   HuskyDanny
🌐
Edureka Community
edureka.co › home › community › categories › others › error attributeerror str object has no...
Error AttributeError str object has no attribute row | Edureka Community
April 4, 2023 - I have code: def add_to_database(object_name, value): workbook = openpyxl.load_workbook(DATABASE_FILE) worksheet ... row, column = 2).value += value
🌐
LabEx
labex.io › tutorials › python-how-to-address-attributeerror-list-object-has-no-attribute-count-417489
How to address AttributeError: 'list' object has no attribute 'count' | LabEx
If the AttributeError occurred because you tried to access an attribute on a None object, you can either check if the object is None before accessing the attribute or use the hasattr() function to check if the attribute exists.
🌐
Real Python
realpython.com › ref › builtin-exceptions › attributeerror
AttributeError | Python’s Built-in Exceptions – Real Python
Catching an AttributeError allows you to provide a graceful degradation or alternative solution when users try to access an attribute that’s missing. Accessing a method or attribute that doesn’t exist in a class or module ... Attempting to access attributes on a NoneType object due to uninitialized or improperly assigned variables
🌐
Quora
quora.com › What-does-AttributeError-function-object-has-no-attribute-iterrows-mean
What does AttributeError: 'function' object has no attribute 'iterrows' mean? - Quora
Answer (1 of 2): What it says… You are trying to access an attribute called iterrows but the object in question does not have such attribute, because it is a function, Without seeing the code we can only guess but it seems that you may have forgotten to write a pair of parentheses after the fun...