web-dev-qa-db-ja.com

WTForms 2.3.0の重大な変更-ImportError:「wtforms.widgets」から名前「HTMLString」をインポートできません

WTForms2.3.0に更新され、重大な変更が加えられました。 werkzeug.1.0.0などの他の要件を調整しようとしましたが、まだうまくいきません。誰かが解決策を見つけましたか?

スタックstraceは次のとおりです。

Traceback (most recent call last):
   File "/usr/local/bin/celery", line 8, in <module>
     sys.exit(main())
   File "/usr/local/lib/python3.8/site-packages/celery/__main__.py", line 16, in main
     _main()
   File "/usr/local/lib/python3.8/site-packages/celery/bin/celery.py", line 322, in main
     cmd.execute_from_commandline(argv)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/celery.py", line 495, in execute_from_commandline
     super(CeleryCommand, self).execute_from_commandline(argv)))
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 289, in execute_from_commandline
     argv = self.setup_app_from_commandline(argv)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 509, in setup_app_from_commandline
     self.app = self.find_app(app)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 531, in find_app
     return find_app(app, symbol_by_name=self.symbol_by_name)
   File "/usr/local/lib/python3.8/site-packages/celery/app/utils.py", line 373, in find_app
     sym = symbol_by_name(app, imp=imp)
   File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 534, in symbol_by_name
     return imports.symbol_by_name(name, imp=imp)
   File "/usr/local/lib/python3.8/site-packages/kombu/utils/imports.py", line 57, in symbol_by_name
     module = imp(module_name, package=package, **kwargs)
   File "/usr/local/lib/python3.8/site-packages/celery/utils/imports.py", line 111, in import_from_cwd
     return imp(module, package=package)
   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
   File "/prosebit/prosebit/blueprints/contact/__init__.py", line 1, in <module>
     from prosebit.blueprints.contact.views import contact
   File "/prosebit/prosebit/blueprints/contact/views.py", line 10, in <module>
     from prosebit.blueprints.contact.forms import ContactForm
   File "/prosebit/prosebit/blueprints/contact/forms.py", line 3, in <module>
     from wtforms_components import EmailField
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/__init__.py", line 3, in <module>
     from .fields import (
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/fields/__init__.py", line 2, in <module>
     from .color import ColorField
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/fields/color.py", line 1, in <module>
     from ..widgets import ColorInput
   File "/usr/local/lib/python3.8/site-packages/wtforms_components/widgets.py", line 5, in <module>
     from wtforms.widgets import html_params, HTMLString, Input
 ImportError: cannot import name 'HTMLString' from 'wtforms.widgets' (/usr/local/lib/python3.8/site-packages/wtforms/widg
ets/__init__.py)

そしてここに私の要件があります:

Flask==1.1.1
werkzeug==0.16.0

# Application server for both development and production.
gunicorn==20.0.4

# Testing and static analysis.
pytest==5.3.2
pytest-cov==2.8.1
mock==3.0.5
flake8==3.7.9

# CLI.
# Click==6.4

# Data and workers.
# psycopg2==2.6.1
psycopg2==2.8.4
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.12

redis==3.3.11
celery==4.4.0

# Forms.
Flask-WTF==0.14.3
WTForms-Components==0.10.4
WTForms-Alchemy==0.16.9

# Utils.
# fake-factory==0.5.7
faker==3.0.0

# Extensions.
flask-debugtoolbar==0.11.0
Flask-Mail==0.9.1
Flask-Login==0.4.1

# Payments.
stripe==2.41.0
gocardless_pro==1.10.0

# Google API requirements
google-api-core==1.16.0
google-cloud-pubsub==1.4.3 # Not compatible with google-api-core: 1.17.0
google-api-python-client==1.8.0
httplib2==0.17.2
oauth2client==4.1.3
google-auth==1.14.0 # Used for google.oauth2.credentials
google-auth-oauthlib==0.4.1
3
polymath

JBLafの回答に加えて、HTMLStringMarkupに置き換えられました。したがって、代わりにfrom markupsafe import Markupを使用してください。

from wtforms.widgets.core import escape_htmlfrom markupsafe import escapeに置き換えられました

WTForms 2.3.1では、これらの用語がエイリアスとして再度追加され、重大な変更の代わりに非推奨の警告が表示されます。

0
polymath