module 'collections' has no attribute 'Mapping' / 'Callable' (tested fix)
AttributeError: module 'collections' has no attribute 'Mapping' (or 'Callable', 'MutableMapping', 'Iterable') appears on Python 3.10 and later. Those classes now exist only in collections.abc. We checked every common alias on Python 3.13 and 3.11 and show the fix for your code and for libraries that still use the old import.
1. The abstract base classes left collections in Python 3.10
Mapping, MutableMapping, Callable, Iterable, Sequence and the other abstract base classes have lived in collections.abc since Python 3.3. The old collections.X aliases were deprecated for years and removed in Python 3.10. We checked on Python 3.13:
import collections, collections.abc, sys
print(sys.version.split()[0])
for name in ["Mapping", "MutableMapping", "Callable", "Iterable", "Sequence", "Hashable"]:
try:
getattr(collections, name)
print(f"collections.{name:15} OK")
except AttributeError as e:
print(f"collections.{name:15} AttributeError: {e}")
print("collections.abc.Mapping:", collections.abc.Mapping)
Output:
3.13.5
collections.Mapping AttributeError: module 'collections' has no attribute 'Mapping'
collections.MutableMapping AttributeError: module 'collections' has no attribute 'MutableMapping'
collections.Callable AttributeError: module 'collections' has no attribute 'Callable'
collections.Iterable AttributeError: module 'collections' has no attribute 'Iterable'
collections.Sequence AttributeError: module 'collections' has no attribute 'Sequence'
collections.Hashable AttributeError: module 'collections' has no attribute 'Hashable'
collections.abc.Mapping: <class 'collections.abc.Mapping'>
Python 3.11 (run in python:3.11-alpine) gives exactly the same output, so this affects every Python from 3.10 on.
2. The fix in your own code: import from collections.abc
from collections.abc import Callable, Mapping, Iterable # works on 3.3+
from collections import OrderedDict, defaultdict, Counter # these never moved
print(isinstance({}, Mapping), isinstance(print, Callable), isinstance("ab", Iterable))
print(Counter("hello").most_common(1), OrderedDict(a=1), defaultdict(int)["x"])
Output:
True True True
[('l', 2)] OrderedDict({'a': 1}) 0
Only the abstract base classes moved. OrderedDict, defaultdict, Counter, deque, namedtuple and ChainMap are still in collections. For type hints, collections.abc.Callable and friends can be used directly (Callable[[int], str]) on Python 3.9+.
3. When the error is inside a library
If the traceback ends in a third-party package, the package itself still uses the old import, which fails with a different message:
try:
from collections import Mapping # what old libraries do
except ImportError as e:
print("ImportError:", e)
Output:
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.13/collections/__init__.py)
Don't patch collections back by hand (collections.Mapping = collections.abc.Mapping): it hides the problem and breaks again elsewhere. Upgrade the package (pip install -U <package>), since nearly every maintained library fixed this before 3.10 was released. If it is abandoned, replace it or pin an older Python for that project. The traceback's last file path tells you which package to upgrade. More on reading these errors in our module has no attribute guide and cannot import name guide.
Frequently asked questions
How do I fix module 'collections' has no attribute 'Mapping'?
Import it from collections.abc: from collections.abc import Mapping. The alias in collections was removed in Python 3.10.
Which names were removed from collections in Python 3.10?
The abstract base classes: Mapping, MutableMapping, Sequence, MutableSequence, Set, MutableSet, Callable, Iterable, Iterator, Hashable, Sized, Container and the rest. OrderedDict, defaultdict, Counter, deque, namedtuple and ChainMap stayed.
The error comes from a library, not my code. What do I do?
Upgrade the library named in the last traceback lines with pip install -U. Old versions use from collections import Mapping, which fails on Python 3.10+ with ImportError: cannot import name 'Mapping' from 'collections'.
Written with AI assistance. Measured on 2026-10-22 on Debian with Python 3.13.5 and in python:3.11-alpine (Python 3.11.17): every common collections ABC alias, the collections.abc imports, and the from-import failure old libraries hit. Every block was run verbatim and its output pasted unedited. PlainHeaders is our extension; Python is free.