ImportError-cannot import name Iterabler from collections python 3-10

The Iterable abstract class was removed from collections in Python 3.10. See the deprecation note in the 3.9 collections docs.
https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes
There are couple of ways to fix the above error.

  • Use any previous version of Python3.3+
  • import from collections.abc class
In [1]:
import sys
sys.version
Out[1]:
'3.9.7 (default, Sep 16 2021, 13:09:58) \n[GCC 7.5.0]'
In [2]:
from collections import Iterable
/tmp/ipykernel_3591499/2097383490.py:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import Iterable

Note the warning above but since version is python3.9, it works.

In Python 3.10, above command will output following error.
ImportError: cannot import name 'Iterable' from 'collections'

To resolve above error, import from collections.abc

In [3]:
from collections.abc import Iterable