i was creating a REST api using flask and while i was about to test it on postman I saw that error

2024/11/15 8:58:42
  File "c:\Users\kally\rest\code\app.py", line 3, in <module>from flask_jwt import JWTFile "C:\Users\kally\AppData\Roaming\Python\Python310\site-packages\flask_jwt\__init__.py", line 16, in <module>import jwtFile "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)
Answer

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.

https://en.xdnf.cn/q/120464.html

Related Q&A

Web scrape get drop-down menu data python

I am trying to get a list of all countries in the webpage https://www.nexmo.com/products/sms. I see the list is displayed in the drop-down. After inspecting the page, I tried the following code but I m…

TypeError(unsupported operand type(s) for ** or pow(): str and int,)

import mathA = input("Enter Wright in KG PLease :") B = input("Enter Height in Meters Please :")while (any(x.isalpha() for x in A)):print("No Letters Please")A = input(&qu…

How can I do assignment in a List Comprehension? [duplicate]

This question already has answers here:How can I do assignments in a list comprehension?(8 answers)Closed 1 year ago.Generally, whenever I do a for loop in python, I try to convert it into a list comp…

KeyError: column_name

I am writing a python code, it should read the values of columns but I am getting the KeyError: column_name error. Can anyone please tell me how to fix this issue. import numpy as np from sklearn.clust…

Find starting and ending indices of list chunks satisfying given condition

I am trying to find the start and stop indices of chunks of positive numbers in a list.cross = [7,5,8,0,0,0,0,2,5,8,0,0,0,0,8,7,9,3,0,0,0,3,2,1,4,5,0,0,0,7,5] For the given example input, the desired o…

How can I Scrape Business Email Contact with python?

this morning I wanted to create a little Software/Script in Python, it was 6am when I started and now Im about to become crazy because its 22pm and I have nothing that works.So basically, I want to do …

Python class that works as list of lists

Im trying to create a python class that can work as a list of lists. However, all Ive managed to develop so far is,class MyNestedList(list): ...Im aware that the above code will work as,my = MyNestedLi…

GPA Python Assignment [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

Tuple Errors Python

I opened Python and attempted to run the following script (btw, this script is what was directly given to me, I havent edited it in any way as its part of an assignment aside from entering the username…

Flatten list of lists within dictionary values before processing in Pandas

Issue:If I need to flatten a list of lists I use something like this list comprehension to flatten into a single list:[item for sublist in l for item in sublist]I have a dictionary where some of the va…