flask_uploads——“ImportError: cannot import name ‘secure_filename‘ from ‘werkzeug‘“

在这里插入图片描述
问题描述:从师兄那里拿来的flask项目,进行各种安装依赖库后,使用Flask_uploads模块开发上传文件功能时,在项目中导入该包时,提示“ImportError: cannot import name ‘secure_filename’ from 'werkzeug”错误。

错误分析:应该是依赖库版本不一致导致的,师兄使用的依赖库较低,而我安装的是最新的,导致这个情况

问题解决:
在这里插入图片描述
将红框内的内容替换成:

from werkzeug.utils import secure_filename
from werkzeug.datastructures import  FileStorage

结果如下:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This error message indicates that there is an issue with importing the `current_app` object from the `flask` module. This object is used to access the current Flask application instance, and is typically used in a context where the application instance is not available through other means. There are a few possible reasons why you might encounter this error: 1. You may be importing `current_app` from the wrong module. Make sure that you are importing it from the `flask` module and not another module with a similar name. 2. You may be importing `current_app` before the Flask application has been created. `current_app` is only available when a Flask application context is active, so if you try to import it outside of a request or application context, you will get this error. Make sure that you are importing `current_app` from within a Flask view function, or from within a function that is called within a Flask view function. 3. There may be a circular import issue in your application. Flask applications can be prone to circular import issues if you're not careful about how you structure your code. If you're importing `current_app` from a module that also imports something from the module where your Flask application instance is created, you may run into this error. Try restructuring your code to avoid circular imports. To resolve this error, you should check your code for the above issues and make sure that you are importing `current_app` correctly and in the right context. You may also want to review the Flask documentation on application context and request context to better understand how they work.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值