关于机器学习模型部署过程中遇到的几个error

目录

  • Flask 500 internal server error
    • 解决
  • jinja2.exceptions.TemplateNotFound: index.html
    • 解决
  • TypeError: __init__() got an unexpected keyword argument 'mothods'
    • 解决
  • Trying to unpickle estimator LogisticRegression from version 0.24.2 when using version 1.1
    • 解决

Flask 500 internal server error

通用错误消息,服务器遇到了一个未曾预料的状况,导致了它无法完成对请求的处理。没有给出具体错误信息。

解决

方法一:

app.run(Debug=True,host='127.0.0.1',port=9090)

方法二:
可能是因为笔者多次运行程序导致内置服务崩溃,关机重启后正常运行

jinja2.exceptions.TemplateNotFound: index.html

解决

flask使用时,要将html文件放在templates目录下,否则会报错

TypeError: init() got an unexpected keyword argument ‘mothods’

解决

报错代码

@app.route('/predict',mothods=['POST','GET'])

笔者将methods错写成了mothods,因此遇到“TypeError: init() got an unexpected keyword argument ‘xxx’”的错误一般要检查xxx的拼写是否错误

Trying to unpickle estimator LogisticRegression from version 0.24.2 when using version 1.1

解决

两个版本的sklearn不一样,序列化的是0.24.2版本的 LogisticRegression 模型,但是另一个python解释器环境中的sklearn是1.1版本的,两者相差太多,容易出现错误

你可能感兴趣的:(#,关于python的一些tip,python,flask)