解决ImportError: cannot import name ‘url_quote‘ from ‘werkzeug.urls‘

发布时间:2024年01月04日

解决ImportError: cannot import name ‘url_quote’ from ‘werkzeug.urls’

在这里插入图片描述

在这里插入图片描述

错误类似如下:

Traceback (most recent call last):
File “MyTranslate.py”, line 2, in
from flask import Flask, request
File “/usr/local/python3/lib/python3.8/site-packages/flask/init.py”, line 5, in
from .app import Flask as Flask
File “/usr/local/python3/lib/python3.8/site-packages/flask/app.py”, line 30, in
from werkzeug.urls import url_quote
ImportError: cannot import name ‘url_quote’ from ‘werkzeug.urls’ (/usr/local/python3/lib/python3.8/site-packages/werkzeug/urls.py)


查看flask的安装版本:

[root@bb4d85446731 ~]# pip38 list | grep -i flask
Flask              2.2.2
WARNING: You are using pip version 19.2.3, however version 23.3.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

安装与flask相同版本的Werkzeug:

[root@bb4d85446731 ~]# pip38 install Werkzeug==2.2.2
Collecting Werkzeug==2.2.2
  Downloading https://files.pythonhosted.org/packages/c8/27/be6ddbcf60115305205de79c29004a0c6bc53cec814f733467b1bb89386d/Werkzeug-2.2.2-py3-none-any.whl (232kB)
     |████████████████████████████████| 235kB 468kB/s
Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/python3/lib/python3.8/site-packages (from Werkzeug==2.2.2) (2.1.3)
Installing collected packages: Werkzeug
  Found existing installation: werkzeug 3.0.1
    Uninstalling werkzeug-3.0.1:
      Successfully uninstalled werkzeug-3.0.1
Successfully installed Werkzeug-2.2.2
WARNING: You are using pip version 19.2.3, however version 23.3.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
文章来源:https://blog.csdn.net/u014374009/article/details/135380153
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。