ImportError in Flask app

When deploying and running Flask app I’m getting an error: ImportError: cannot import name ‘Mapping’ from ‘collections’

Stack trace:

2022-10-15T06:44:22.204 app[4b68ed47] fra [info] from collections import Mapping

2022-10-15T06:44:22.204 app[4b68ed47] fra [info] ImportError: cannot import name 'Mapping' from 'collections' (/layers/paketo-buildpacks_cpython/cpython/lib/python3.10/collections/__init__.py)

2022-10-15T06:44:22.204 app[4b68ed47] fra [info] [2022-10-15 06:44:22 +0000] [538] [INFO] Worker exiting (pid: 538)

2022-10-15T06:44:22.279 app[4b68ed47] fra [info] [2022-10-15 06:44:22 +0000] [520] [INFO] Shutting down: Master

2022-10-15T06:44:22.279 app[4b68ed47] fra [info] [2022-10-15 06:44:22 +0000] [520] [INFO] Reason: Worker failed to boot.

2022-10-15T06:44:23.182 app[4b68ed47] fra [info] Starting clean up.

I’d be happy to hear ideas what it can be caused by as I’m quite desperate now :pray:. My app looks very similar to GitHub - fly-apps/python-hellofly-flask: A Pythonic version of the Hellofly example.

Thanks for tips

In Python 3.10, Mapping is under the collections.abc namespace, not the top level collections namespace: collections.abc — Abstract Base Classes for Containers — Python 3.10.8 documentation

Are you developing with a different Python version locally?

Hi shugel, thanks for help. I’ve discovered that I had mixed versions of python locally. So fixing this I was able to locally identify the problem. All good now.