本文主要是介绍解决ImportError: cannot import name ‘url_quote‘ from ‘werkzeug.urls‘,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
解决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.2Downloading 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: WerkzeugFound existing installation: werkzeug 3.0.1Uninstalling 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.
这篇关于解决ImportError: cannot import name ‘url_quote‘ from ‘werkzeug.urls‘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!