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
Use older version of python (eg 3.8)
That's about python version. in most time python 3.10 have this problems.
You can solve this problem with use python 3.9 or 3.8 version. or if error from packages like python-docx or other packages about MS you can probably solve it by using pipwin.
As stated by others, this is caused by a change in the collections interface starting with Python 3.10. As far as I can see there are three options to mitigate this issue so far:
Revert to Python 3.9.
If the error occurs in a third-party library, try to update this library first (pip install <package> --upgrade).
Patch the code manually.
For patching the ImportError, see https://stackoverflow.com/a/69727802/13994294.
In my environment the problem was solved using bug fix Python version 3.10.2
I had the same problem with requests 2.7.0 ,but right now I'm using requests 2.27.1 and python 3.10.2 with no problem.