Cause of the error:
If you tried the import in python3.9.x
, it becomes clear:
╭─ ~/command_line $ ───────────────────────────────────────────────────── ✔ │ 22:02:44
╰─ python3
Python 3.9.10 (main, Jan 15 2022, 11:40:53)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import Mapping
<stdin>: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
It clearly mentions that in 3.10 it will stop working. So to use please change the version to python3.9 or below.
If you are using pipenv to manage your virtual-environment, then the steps could be as follow:
$ pipenv --rm # to remove the virtual env
$ exit # to exit the virtual env
$ vim Pipfile # here change the version to '3.9' by replacing '3.10'
$ pipenv shell # this will create a virtual env with 3.9
$ pipenv install # to install the requirements
We just switched from python3.10
to python3.9
, which supports the code for now. But I would suggest to use John R Perry's solution(the accepted one) instead for long term usage.