Importerror: cannot import name ‘iterable’ from ‘collections’

Are you encountering reads “ImportError: cannot import name ‘iterable’ from collections“?

This error means that the code is trying to import the “iterable” module from the “collections” package, but it cannot find it.

Obviously, there is a version mismatch between the Python version and the package being imported.

So in this article, we determined how to fix this error…

What is Importerror: cannot import name ‘iterable’ from ‘collections’?

The error “ImportError: cannot import name ‘iterable’ from ‘collections‘” means that there was an attempt to import the ‘iterable’ module from the ‘collections’ module in Python, but the interpreter was unable to find it.

Moreover, the error can occur if the version of Python being used is older than the one that introduced the ‘iterable’ module, or if there is an issue with the Python installation or environment.

More specifically, Python 3.10 removed the ‘iterable’ abstract class from the ‘collections’ module.

Now, the iterable class can be imported from ‘collections.abc’ instead of ‘collections’.

How to fix this cannot import name ‘iterable’ from ‘collections’

As mentioned above the quickest way to fix the error is to import ‘Iterable’ class from ‘collections.abc’ rather than ‘collections’.

From this import statement:

from collections import Iterable

# Use Iterable class as usual

To this import statement.

from collections.abc import Iterable

# Use Iterable class as usual

Other Solution to fix the error

Here are other solutions you can consider when the given above does not fix it.

📌 Upgrade Python

If you are using an outdated version of Python, the first solution is to upgrade to the latest version. This will ensure that your Python version supports the “iterable” module.

📌 Upgrade package

If you are using an outdated version of the “collections” package, you can upgrade it using pip, the package manager for Python.

You can use the following command to upgrade the package:

pip install --upgrade collections

📌 Uninstall conflicting packages

If you have multiple versions of the “collections” package installed in your system, you can uninstall the conflicting packages using pip.

You can use the following command to uninstall the package:

pip uninstall collections

Once you have uninstalled the conflicting packages, you can reinstall the package using the following command:

pip install collections

Anyway, here are other fixed errors you can consider when somehow you might encounter them.

Conclusion

To conclude what we have explained about “ImportError: cannot import name ‘iterable’ from collections‘” error in Python, the first thing you should do is to check your Python version and ensure that you have the latest version installed.

You should also ensure that you have the latest version of the “collections” package installed, and if you have multiple versions of the package installed, you should uninstall the conflicting packages.

I hope this article has helped you fix the error.

Until next time! 😊

Frequently Asked Questions

What is Python ImportError and what causes it?

ImportError is raised when an import fails for any reason. The most specific subtype is ModuleNotFoundError (no such module). Plain ImportError typically means the module exists but a name inside it can’t be imported, e.g. ‘cannot import name X from Y’ (X was renamed, removed, or moved between versions of Y). Common with library version mismatches.

How do I fix ‘cannot import name X from Y’?

Three steps: (1) Check the library version: pip show Y. (2) Check the changelog of Y, X may have been renamed or removed in a recent release. (3) Either pin to an older Y version (pip install Y==1.x.y) or update your code to the new import path. Common 2025-2026 examples: Werkzeug url_decode removed, Pillow ANTIALIAS renamed to LANCZOS.

Why does the import work in REPL but fail in script?

Two reasons. (1) Different Python interpreter: REPL uses one Python, your script uses another. Run python –version both times. (2) Different working directory: REPL is started where you have access to local modules, script is run from a different cwd. Add the project path to sys.path or use python -m to run as a module.

How do I avoid circular import errors?

Circular imports happen when module A imports B and B imports A at the top level. Three fixes: (1) Move one import inside the function that uses it (lazy import). (2) Restructure code so A and B both import from a third module C. (3) Use TYPE_CHECKING for type-hint-only imports: if TYPE_CHECKING: from a import X.

Where can I find more ImportError fixes?

Browse the ImportError reference hub for 67+ specific fixes (Flask, Werkzeug, Django, ML library versions). For missing-module cases see ModuleNotFoundError. For Python setup help see Python Tutorial hub.