![](/img/trans.png)
[英]I'm having trouble creating an API Post using Python flask, SQL workbench and Postman
[英]i was creating a REST api using flask and while i was about to test it on postman I saw that error
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)
擴展我的評論:
如文檔中所述, Mapping
已移至 v3.3 中的collections.abc
並自 v3.9 起棄用(但在 v3.8 之前仍保持可見以實現向后兼容性)。
您的錯誤源於使用過時的導入 - 您需要升級使用過的pyjwt/jwt
- 特別是它的/api_jwt.py
。 當前版本的
https://github.com/jpadilla/pyjwt/blob/master/jwt/api_jwt.py
自 2018 年 11 月提交以來,使用正確的導入。
那個錯誤
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections'
對你說, collection
包中沒有Mapping
。 請檢查文檔
Gabriel Kalango 請問你是如何解決這個問題的,因為我也有同樣的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.