Attributeerror: list object has no attribute items [SOLVED]
Hey, are you stuck and don’t know how to fix the “attributeerror: list object has no attribute items” error message? Worry no more, because in this article we are going …
itsourcecode.com hosts 170+ documented fixes for Python AttributeError messages: the most common runtime error after TypeError. From beginner-level confusion ('NoneType' object has no attribute 'split') to library-version pain (module 'numpy' has no attribute 'float' after NumPy 1.20+), this archive groups every documented error by root cause. Each post explains why the attribute is missing and gives 2-4 alternative fixes with code examples.
What is an AttributeError?
A Python AttributeError is raised when you try to access an attribute or method on an object that doesn’t have it. The error message always tells you both the object type and the missing attribute, for example AttributeError: 'list' object has no attribute 'items' means you called .items() on a list, but only dicts have that method. The error has two forms:
Instance form: 'X' object has no attribute 'Y', the value at runtime isn’t the type you expected
Module form: module 'X' has no attribute 'Y', the function/class you’re importing no longer exists in that version of the library
How to debug any AttributeError in 4 steps
Read both names in the error. The message gives you the object type AND the missing attribute. Note both, they tell you what’s wrong together.
Print the type of the object. Add print(type(x)) on the line before the error. If the error says 'NoneType' object has no attribute 'split', the value is actually None, usually because a function returned nothing when you expected a string.
If the error is “module X has no attribute Y”, check the library version. Run pip show to see installed version. Compare to the version that had the attribute, often the API was deprecated and renamed. Common offenders: NumPy (np.float, np.int, np.long removed in 1.20+), pandas (.ix removed in 1.0+), Keras (keras.optimizers.Adam moved), Selenium (find_element_by_id removed in 4.0+).
Check the import path. from numpy import float and numpy.float are different namespaces and different lookups. Many AttributeErrors come from a sub-package that moved or was renamed across versions.
Most common root causes (in order of frequency)
Value is None when you expected an object: function returned None, regex match failed, dict lookup returned None, BeautifulSoup didn’t find the element
Library version mismatch: API was deprecated and removed (numpy 1.20+, pandas 1.0+, Keras 2.x → tf.keras, Selenium 4)
Wrong type altogether: calling .items() on a list, .append() on a string, .read() on a dict
Python 2 → 3 migration: old code using dict.iteritems(), dict.has_key(), urllib.urlopen
Module re-org: imports from tensorflow.contrib (removed), keras.optimizers.Adam (moved to tf.keras.optimizers)
Typo in attribute name: beginners hit this most, especially when an IDE doesn’t autocomplete
Featured AttributeError fixes by type
🟢 Python built-in types: NoneType, str, list, dict, set, tuple
These errors come from runtime type confusion, your code expects one type but got another. Almost always fixable with a one-line type check or rewriting the previous line that returned the wrong value.
NoneType errors (14 posts): the most common AttributeError class. A function/method returned None when you expected a string, list, or object.
‘NoneType’ object has no attribute ‘split’
‘NoneType’ object has no attribute ‘strip’
‘NoneType’ object has no attribute ‘find’ (BeautifulSoup)
‘NoneType’ object has no attribute ‘text’
‘NoneType’ object has no attribute ‘cursor’ (database)
str errors (10 posts): calling list/dict methods on a string.
‘str’ object has no attribute ‘keys’
‘str’ object has no attribute ‘get’
‘str’ object has no attribute ‘append’
‘str’ object has no attribute ‘remove’
‘str’ object has no attribute ‘write’
‘str’ object has no attribute ‘decode’ (Python 3 migration)
list errors (10 posts): calling string/dict methods on a list.
‘list’ object has no attribute ‘items’
‘list’ object has no attribute ‘strip’, 2026 Guide
‘list’ object has no attribute ‘shape’, 2026 Guide
‘list’ object has no attribute ‘join’
dict errors (6 posts): Python 2 methods removed in Python 3.
‘dict’ object has no attribute ‘iteritems’ (Py3 migration)
‘dict’ object has no attribute ‘has_key’ (Py3 migration)
‘dict’ object has no attribute ‘add’, 2026 Guide
‘dict’ object has no attribute ‘read’
set, float, bytes errors
‘set’ object has no attribute ‘items’
‘float’ object has no attribute ‘split’
🐼 pandas (DataFrame, Series): 13 posts
pandas had multiple API breaks between 0.x → 1.x → 2.x. Old code using .ix, .append(), or older indexing methods raises AttributeError on modern pandas.
‘DataFrame’ object has no attribute ‘ix’ (use .loc / .iloc)
‘DataFrame’ object has no attribute ‘unique’
‘DataFrame’ object has no attribute ‘concat’
‘DataFrame’ object has no attribute ‘write’
‘DataFrame’ object has no attribute ‘_get_object_id’
‘DataFrame’ object has no attribute ‘withColumn’ (PySpark vs pandas)
‘Series’ object has no attribute ‘strftime’
‘Series’ object has no attribute ‘split’
Pandas .dt accessor with datetimelike values
module ‘pandas’ has no attribute ‘read_csv’
🔢 NumPy (module + ndarray): 16 posts
NumPy 1.20 deprecated and removed many type aliases (np.float, np.int, np.long, np.bool). Code from 2019 or earlier hits these errors immediately on modern NumPy.
module ‘numpy’ has no attribute ‘object’
module ‘numpy’ has no attribute ‘float’
module ‘numpy’ has no attribute ‘long’
module ‘numpy’ has no attribute ‘ndarray’, 2026 Guide
🤖 TensorFlow & Keras: 15 posts
TensorFlow 2.x reorganized the API: tensorflow.contrib was removed, optimizers moved into tf.keras.optimizers, and many sub-modules were merged or deprecated.
module ‘tensorflow.compat.v1’ has no attribute ‘contrib’
module ‘tensorflow’ has no attribute ‘set_random_seed’
module ‘keras.utils’ has no attribute ‘Sequence’
module ‘keras.optimizers’ has no attribute ‘Adam’
‘Tensor’ object has no attribute ‘numpy’
🔥 PyTorch & TorchText: 3 posts
module ‘torchtext.data’ has no attribute ‘Field’ (torchtext 0.9+)
module ‘torch._C’ has no attribute ‘_cuda_setDevice’
📈 Matplotlib (module-level): 2 posts
module ‘matplotlib’ has no attribute ‘plot’ (use pyplot)
module ‘matplotlib’ has no attribute ‘get_data_path’
‘AxesSubplot’ object has no attribute ‘savefig’
👁️ OpenCV (cv2): 2 posts
module ‘cv2’ has no attribute ‘xfeatures2d’ (need opencv-contrib)
module ‘cv2’ has no attribute ‘_registerMatType’
🕷️ Selenium WebDriver: 3 posts
Selenium 4 removed the find_element_by_* methods. Use find_element(By.X, ...) instead.
‘WebDriver’ object has no attribute ‘find_element_by_class_name’
module ‘selenium.webdriver’ has no attribute ‘PhantomJS’ (deprecated)
module ‘selenium.webdriver’ has no attribute ‘Opera’
⚙️ Standard library & misc modules
module ‘datetime’ has no attribute ‘now’
module ‘asyncio’ has no attribute ‘run’ (Python 3.7+)
module ‘collections’ has no attribute ‘Iterable’ (Py3.10+ moved to collections.abc)
module ‘urllib’ has no attribute ‘urlopen’ (Py3: use urllib.request)
AttributeError: __enter__ (context manager protocol)
module ‘h11’ has no attribute ‘Event’
‘entrypoints’ object has no attribute ‘get’
‘API’ object has no attribute ‘search’ (Tweepy)
2026 Updated Guides: featured AttributeError fixes
These guides were rewritten or expanded in 2026 with current library versions, minimal reproductions, and 3-4 alternative fixes each.
module ‘numpy’ has no attribute ‘ndarray’: NumPy 1.20+ migration
‘list’ object has no attribute ‘strip’: String method confusion
‘list’ object has no attribute ‘shape’: NumPy vs list confusion
‘dict’ object has no attribute ‘add’: set vs dict confusion
module ‘pandas’ has no attribute ‘read_csv’: shadowed import
‘DataFrame’ object has no attribute ‘ix’: pandas 1.0+ migration (use .loc / .iloc)
Pandas .dt accessor error: datetime column conversion
‘Tensor’ object has no attribute ‘numpy’: TensorFlow eager execution
‘WebDriver’ has no attribute ‘find_element_by_class_name’: Selenium 4 migration
module ‘asyncio’ has no attribute ‘run’: Python 3.7+ async
‘tensorflow.compat.v1’ has no attribute ‘contrib’: TF 2.x migration
‘set’ object has no attribute ‘items’: set vs dict
‘list’ object has no attribute ‘items’: list of dicts vs dict
AttributeError: __enter__: using with on non-context-manager
Related error categories
AttributeError is one of 10 hubs in our Python & JavaScript error reference cluster, 980+ documented fixes total. If your error isn’t about a missing attribute, jump to the right hub below:
TypeError Reference, 220+ Python & JS TypeError fixes
ModuleNotFoundError Reference, 198+ Python import errors
ValueError Reference, 100+ library-specific Python ValueError fixes
ImportError Reference, 67+ “cannot import name X from Y” fixes
NameError Reference, 49+ Python “name X is not defined” fixes
RuntimeError Reference, 49+ PyTorch CUDA, asyncio, Flask runtime errors
SyntaxError Reference, 48+ Python & JavaScript parsing errors
ReferenceError Reference, 34+ JavaScript “is not defined” fixes
HTTP Error Reference, 35+ HTTP status code fixes
Python Tutorial, beginner-to-intermediate Python lessons
About this AttributeError reference
This AttributeError reference has been built since 2015 by PIES Information Technology Solutions in Binalbagan, Negros Occidental, Philippines. Every post in the collection started as a real error encountered in production code, by us, by our clients, or by readers who emailed us with their tracebacks. Used by 12,000+ Python developers monthly across the Philippines, India, the United States, and beyond. If your AttributeError isn’t here, send the full traceback to our contact form and we’ll add it.
Hey, are you stuck and don’t know how to fix the “attributeerror: list object has no attribute items” error message? Worry no more, because in this article we are going …
Are you dealing with Attributeerror: ‘connection’ object has no attribute ‘sftp_live’ error? Well, in this article we will show you various solutions to fix this error as well as how …
In this article, we will discuss what this error message DataFrame’ object has no attribute ‘withColumn’ means, the reasons why it might occur, and how to fix it. We will …
If Python has ever stopped your program with AttributeError: ‘NoneType’ object has no attribute ‘…’, you’ve met the most common runtime error in modern Python. It shows up in scraping …
This time we will deal with Attributeerror: module serial has no attribute serial error. We will show various solutions and how this error occurs. But before proceeding to solutions, let’s …
The “attributeerror: series object has no attribute split” is an error message that is raised when you are trying to use the split() method on a Pandas Series object. If …
In this article, we will provide you with the solution to the error “attributeerror: type object ‘datetime.datetime’ has no attribute ‘timedelta’.” Wondering what this error is and why it occurs? …
As a Python developer, you might have encountered this error message “AttributeError: ‘str’ object has no attribute ‘values’“. This error typically occurs when you are trying to access a non-existent …
Having difficulties fixing Attributeerror: module ‘whois’ has no attribute ‘whois’ in your python code? Don’t worry, this article is for you. In this article, we will discuss the possible causes …
In this article, we will take a closer look at this error Attributeerror: ‘dataframe’ object has no attribute ‘write’. Moreover, we will show you various solutions as well as possible …
The attributeerror: ‘tfidfvectorizer’ object has no attribute ‘get_feature_names’ is an error message while working with tfidfvectorizer in Python. This error indicates that there is an issue with the get_feature_names() method …
It is very common to encounter errors when you are trying to create a new program in Python. One of the most common errors in Python is the AttributeError: exit. In …
In this article, we will talk about the error “attributeerror: module importlib._bootstrap has no attribute sourcefileloader” in Python. In addition, we’ll also provide you with how to solve this error. …