报错问题:ImportError: cannot import name ‘ParameterSource’ from ‘click.core’
问题:
报错信息:
ImportError: cannot import name ‘ParameterSource’ from ‘click.core’
(d:\programdata\conda\cwgis) PS E:\project\python> & d:/programdata/conda/cwgis/python.exe e:/project/python/OCR/publish.py
Traceback (most recent call last):File "e:\project\python\OCR\publish.py", line 1, in <module>from flask import Flask, request, jsonifyFile "D:\programdata\conda\cwgis\lib\site-packages\flask\__init__.py", line 2, in <module>from .app import Flask as FlaskFile "D:\programdata\conda\cwgis\lib\site-packages\flask\app.py", line 34, in <module>from . import cliFile "D:\programdata\conda\cwgis\lib\site-packages\flask\cli.py", line 15, in <module>from click.core import ParameterSource
ImportError: cannot import name 'ParameterSource' from 'click.core' (D:\programdata\conda\cwgis\lib\site-packages\click\core.py)
解决办法:
#报错:ImportError: cannot import name ‘ParameterSource’ from ‘click.core’
原安装click版本为8.1.7本
查看版本号列表
pip index versions click
随机选择一个版本8.0.0版本,安装时提示flask 2.3.2 requires click>=8.1.3,
故再次选择安装8.1.3版本 OK
pip install click==8.1.3
click包版本列表情况
(d:\programdata\conda\cwgis) C:\Users\hsgpc>pip index versions click
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
click (8.1.7)
Available versions: 8.1.7, 8.1.6, 8.1.5, 8.1.4, 8.1.3, 8.1.2, 8.1.1, 8.1.0, 8.0.4, 8.0.3, 8.0.2, 8.0.1, 8.0.0, 7.1.2, 7.1.1, 7.1, 7.0, 6.7, 6.6, 6.5, 6.4, 6.3, 6.2, 6.1, 6.0, 5.1, 5.0, 4.1, 4.0, 3.3, 3.2, 3.1, 3.0, 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0, 1.1, 1.0, 0.7, 0.6, 0.5.1, 0.5, 0.4, 0.3, 0.2, 0.1INSTALLED: 7.1.2LATEST: 8.1.7
问题代码:
from flask import Flask, request, jsonify
import paddleocr#报错:ImportError: cannot import name 'ParameterSource' from 'click.core'
#pip index versions click #查看版本号列表
#随机选择一个版本8.0.0版本,安装时提示flask 2.3.2 requires click>=8.1.3,
#故再次选择安装8.1.3版本 OK
#pip install click==8.1.3print(__name__)
app = Flask(__name__)@app.route('/ocr', methods=['POST'])
def ocr():data = request.get_json()image_path = data['image_path'] # 从请求中获取图像路径ocr_result = paddleocr.ocr(image_path, use_gpu=False) # 调用PaddleOCR模型进行图像识别return jsonify(ocr_result) # 将识别结果以JSON格式返回给客户端if __name__ == '__main__':app.run()
本blog地址:https://blog.csdn.net/hsg77
—the—end—