问题描述:从师兄那里拿来的flask项目,进行各种安装依赖库后,使用Flask_uploads模块开发上传文件功能时,在项目中导入该包时,提示“ImportError: cannot import name ‘secure_filename’ from 'werkzeug”错误。
错误分析:应该是依赖库版本不一致导致的,师兄使用的依赖库较低,而我安装的是最新的,导致这个情况
问题解决:
将红框内的内容替换成:
from werkzeug.utils import secure_filename
from werkzeug.datastructures import FileStorage
结果如下: