I keep getting an error that says
AttributeError: \'NoneType\' object has no attribute \'something\'
The NoneType
is the type of the value None
. In this case, the variable lifetime
has a value of None
.
A common way to have this happen is to call a function missing a return
.
There are an infinite number of other ways to set a variable to None, however.
You can get this error with you have commented out HTML in a Flask application. Here the value for qual.date_expiry is None:
<!-- <td>{{ qual.date_expiry.date() }}</td> -->
Delete the line or fix it up:
<td>{% if qual.date_attained != None %} {{ qual.date_attained.date() }} {% endif %} </td>
if we assign something like the below, it will throw error as "AttributeError: 'NoneType' object has no attribute 'show'"
df1=df.withColumn('newAge',df['Age']).show()
You have a variable that is equal to None and you're attempting to access an attribute of it called 'something'.
foo = None
foo.something = 1
or
foo = None
print(foo.something)
Both will yield an AttributeError: 'NoneType'