克隆源码后,使用requirements文件安装依赖,并启动框架。
Traceback (most recent call last):
File "/root/OlivOS/main.py", line 21, in
import OlivOS
File "/root/OlivOS/OlivOS/init.py", line 35, in
from . import flaskServerAPI
File "/root/OlivOS/OlivOS/flaskServerAPI.py", line 18, in
from flask import Flask
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/init.py", line 7, in
from .app import Flask as Flask
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/app.py", line 28, in
from . import cli
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/cli.py", line 18, in
from .helpers import get_debug_flag
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/helpers.py", line 16, in
from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/werkzeug/urls.py)
Describe
源码部署时,使用requirements文件安装依赖后无法正常启动框架
To Reproduce
克隆源码后,使用requirements文件安装依赖,并启动框架。 Traceback (most recent call last): File "/root/OlivOS/main.py", line 21, in
import OlivOS
File "/root/OlivOS/OlivOS/init.py", line 35, in
from . import flaskServerAPI
File "/root/OlivOS/OlivOS/flaskServerAPI.py", line 18, in
from flask import Flask
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/init.py", line 7, in
from .app import Flask as Flask
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/app.py", line 28, in
from . import cli
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/cli.py", line 18, in
from .helpers import get_debug_flag
File "/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/flask/helpers.py", line 16, in
from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/root/miniconda3/envs/OlivOS/lib/python3.9/site-packages/werkzeug/urls.py)
解决办法 通过搜索工具搜索相关内容,查询到Werkzeug 3.0.0删除了以前不推荐的代码,Flask没有正确指定依赖项。 指定Werkzeug为2.2.2后可以正常启动。 pip3 install Werkzeug==2.2.2
是否有更优雅的方式解决这个问题,或者是不是我的操作有问题?
Expected behavior
No response
Screenshots
No response
Desktop (please complete the following information)
Linux-Ubuntu22.04 python3.9及3.10均出现此问题
Smartphone (please complete the following information)
none
Additional context
none