[英]ImportError: cannot import name 'FileStorage' from 'werkzeug'
[英]ImportError: cannot import name 'url_encode' from 'werkzeug'
我目前正在使用flask-wtf version 0.14.2
wtforms version 2.21
和wtforms version 2.21
flask-wtf version 0.14.2
環境,但我無法解決這個ImportError: cannot import name 'url_encode' from 'werkzeug'
以下代碼是完整的回溯。
Traceback (most recent call last):
File "run.py", line 1, in <module>
from flaskblog import app
File "/Users/justinding/Desktop/test/test_wesite/flaskblog/__init__.py", line 10, in <module>
from flaskblog import routes
File "/Users/justinding/Desktop/test/test_wesite/flaskblog/routes.py", line 4, in <module>
from flaskblog.forms import RegistrationForm,LoginForm
File "/Users/justinding/Desktop/test/test_wesite/flaskblog/forms.py", line 1, in <module>
from flask_wtf import FlaskForm
File "/opt/anaconda3/envs/smartbox/lib/python3.7/site-packages/flask_wtf/__init__.py", line 17, in <module>
from .recaptcha import *
File "/opt/anaconda3/envs/smartbox/lib/python3.7/site-packages/flask_wtf/recaptcha/__init__.py", line 2, in <module>
from .fields import *
File "/opt/anaconda3/envs/smartbox/lib/python3.7/site-packages/flask_wtf/recaptcha/fields.py", line 3, in <module>
from . import widgets
File "/opt/anaconda3/envs/smartbox/lib/python3.7/site-packages/flask_wtf/recaptcha/widgets.py", line 5, in <module>
from werkzeug import url_encode
ImportError: cannot import name 'url_encode' from 'werkzeug' (/opt/anaconda3/envs/smartbox/lib/python3.7/site-packages/werkzeug/__init__.py)
在您的需求文件中設置 werkzeug==0.16.1 可以修復它。 問題出在 1.0.0 版本上
猜測錯誤與新版本的werkzeug有關。 在新的 werkzeug 版本中沒有“url_encode”。所以嘗試像這樣安裝一個舊版本的 werkzeug:“pip install werkzeug==0.16.0”我用這個解決方案修復了
嘗試從 werkzeug.urls 導入
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.