1、起因
前段时间折腾宝塔面板,装不上宝塔云控,强行执行btpip install -r requirements.txt
,结果把宝塔的Python环境搞炸了,删掉重装。
然而,重装宝塔Python环境并没有解决我的问题。
2、错误描述
在宝塔面板的文件管理页面,点击下载文件,会提示:
1 | 出错了,面板运行时发生错误! TypeError: send_file() got an unexpected keyword argument 'etag' REQUEST_DATE: 2023-01-23 21:19:14 PAN_VERSION: 7.9.7 OS_VERSION: CentOS 7.9.2009 x86_64(Py3.7.9) REMOTE_ADDR: 211.156.80.226 REQUEST_URI: GET /download?filename=%2Fwww%2Fwwwroot%2Furl%2Fgo_xxWdbE.tar.gz REQUEST_FORM: {} USER_AGENT: Mozilla/5.0 (Linux; Android 9; CMR-W09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 EdgA/108.0.1462.54 Traceback (most recent call last): File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/www/server/panel/BTPanel/__init__.py", line 1025, in download max_age=0) TypeError: send_file() got an unexpected keyword argument 'etag' |
可以看到,其中提到了 Flask。
在其他服务器使用btpip show flask
查看,Flask 版本应为2.2.2
。
3、解决方法
执行:
1 | btpip install flask=2.2.2 |
重启面板:
1 | bt 1 |
完美解决问题。
解决宝塔面板 Flask 版本不正确导致下载文件报错
评论