-3
  File "c:\Users\kally\rest\code\app.py", line 3, in <module>
    from flask_jwt import JWT
  File "C:\Users\kally\AppData\Roaming\Python\Python310\site-packages\flask_jwt\__init__.py", line 16, in <module>
    import jwt
  File "C:\Users\kally\AppData\Roaming\Python\Python310\site-packages\jwt\__init__.py", line 19, in <module>   
    from .api_jwt import (
  File "C:\Users\kally\AppData\Roaming\Python\Python310\site-packages\jwt\api_jwt.py", line 5, in <module>     
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Program Files\Python310\lib\collections\__init__.py)
jps
  • 20,041
  • 15
  • 75
  • 79
  • 1
    https://docs.python.org/3/library/collections.html 3.10 ... no Mapping in collections. The [Mapping](https://docs.python.org/3.7/library/collections.abc.html#collections.abc.Mapping) was moved to collections.abc.mapping in 3.3 and si deprecated from 3.9 onward but up until 3.8 it was still visible. – Patrick Artner Nov 04 '21 at 12:03

2 Answers2

1

Expanding on my comment:

As described in the documentation, Mapping was moved to collections.abc in v3.3 and is deprecated since v3.9 (while still left visible for backwards compatability until v3.8).

Your error stems from using outdated imports - you would need to upgrade the used pyjwt/jwt - especially its /api_jwt.py. The current version of

https://github.com/jpadilla/pyjwt/blob/master/jwt/api_jwt.py

uses the correct imports since this commit in November 2018.

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
  • to be very honest i dont understand can you explain it like you are explaining it to a novice – Gabriel kalango Nov 04 '21 at 13:51
  • @gabrielkalango You are using OLD software in your imports. These OLD things use syntax for importing the Mapping class that no longer works (since 3.9). You need to update your modules that are imported: [how-do-i-update-a-python-package](https://stackoverflow.com/questions/5183672/how-do-i-update-a-python-package) - this may or may not break other stuff so be careful – Patrick Artner Nov 05 '21 at 09:11
0

That error

from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' 

is saying to you, that there is no Mapping in collection package. Please check doc

Dharman
  • 30,962
  • 25
  • 85
  • 135
mrvol
  • 2,575
  • 18
  • 21