Fixing 'AttributeError: module collections has no attribute Callable' in Python 3.10+

beginner🐍 Python2026-07-14| Python 3.10, 3.11, 3.12, and 3.13; common on Windows, macOS, and Linux when running older packages like Flask 1.x or Jinja2 2.x.

Error Message

AttributeError: module 'collections' has no attribute 'Callable'
#python#collections#python310#backend#debugging

The Quick Fix

Python 3.10 finally pulled the plug on several aliases that had been deprecated since version 3.3. The fix is simple: shift your imports from collections to collections.abc.

# ❌ Fails in Python 3.10+
import collections
def is_function(obj):
    return isinstance(obj, collections.Callable)

# ✅ Works in all versions
from collections.abc import Callable
def is_function(obj):
    return isinstance(obj, Callable)

If this error triggers inside a library you didn't write, try a quick update first. Run this in your terminal:

pip install --upgrade <package_name>

Why This Happened

For nearly nine years, Python maintained duplicate references for Abstract Base Classes (ABCs). You could find them in both collections and collections.abc. This redundancy was intended to give developers time to migrate their code after the 2012 release of Python 3.3.

That grace period ended with Python 3.10. Any library that hasn't been updated since 2021 is likely to hit this wall. While Callable is the most common culprit, you might see the same error for Iterable, Mapping, MutableMapping, or Sequence.

Fixing Your Own Code

If you have access to the source code, you should update the imports immediately. It makes your code future-proof and cleaner.

Option 1: Modern Import (Best Practice)

Instead of importing the entire collections module, grab exactly what you need from the abc submodule.

# Old way:
# import collections
# my_list = isinstance(obj, collections.Sequence)

# New way:
from collections.abc import Sequence
my_list = isinstance(obj, Sequence)

Option 2: Support for Very Old Python Versions

Do you need to support Python 2.7 and 3.12 simultaneously? Use a try-except block to handle the import gracefully across generations.

try:
    from collections.abc import Callable
except ImportError:
    # Fallback for Python versions older than 3.3
    from collections import Callable

Fixing Broken Third-Party Libraries

You’ll often see this error when using older versions of requests, PyYAML, or Jinja2. If you just upgraded your server to Ubuntu 22.04 or macOS Sonoma, your old virtual environments might suddenly break.

Step 1: Find the Culprit

Check your terminal's traceback. It will point to a specific file in your site-packages folder. For example, if you see jinja2/tests.py in the error log, you know Jinja2 is the problem.

Step 2: Update the Package

Most popular libraries released fixes years ago. Update them to the latest version to resolve the conflict:

pip install --upgrade jinja2 PyYAML requests

Step 3: The "Monkeypatch" Band-Aid

Sometimes you're stuck with a legacy library that is no longer maintained. If you can't edit its source code, use a "monkeypatch." Add this snippet to the very top of your main.py or manage.py file, before any other imports.

import collections

# Manually re-add the missing attributes
if not hasattr(collections, 'Callable'):
    import collections.abc
    collections.Callable = collections.abc.Callable
    collections.Iterable = collections.abc.Iterable
    collections.Mapping = collections.abc.Mapping
    collections.MutableMapping = collections.abc.MutableMapping
    collections.Sequence = collections.abc.Sequence

Verification

Verify the fix by running a quick one-liner. It should print "Success" without any errors:

python3 -c "from collections.abc import Callable; print('Success')"

If you used the monkeypatch, restart your application. The AttributeError should vanish, allowing your app to boot normally on Python 3.10 or newer.

Further Reading

Related Error Notes