in VS Code ImportError: cannot import name ‘Mapping’ from ‘collections’

Total
0
Shares

I am trying to connect to Postgress and create a folder test.db via Flask.
When I run "python3" in the terminal and from there when I run "from app import db" I get an import error:

ImportError: cannot import name 'Mapping' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

I have tried all the troubleshooting but none of them worked. Please advise.
Here is the full stack:
full stack error


Solution

As Mitra said above, change:

from collections import Mapping

to

from collections.abc import Mapping

Source: StackOverflow.com

Leave a Reply

Your email address will not be published. Required fields are marked *