skip to Main Content

WTForms was updated to 2.3.0 with a breaking change. I have tried adjusting other requirements such as werkzeug.1.0.0 but no luck yet. Has anyone found a solution?

Here is the stack 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)

And here are my requirements:

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

2

Answers


  1. Chosen as BEST ANSWER

    Adding to JBLaf's answer, HTMLString was replaced with Markup. So use from markupsafe import Markup instead.

    from wtforms.widgets.core import escape_html was also replaced by from markupsafe import escape

    In WTForms 2.3.1 these terms are re-added as aliases and a deprecation warning is shown instead of a breaking change.


  2. Looking at your logs, it seems that WTForms 2.3.0 (released a few hours ago) replaced HTMLString :
    https://github.com/wtforms/wtforms/issues/581


    Right now, wtforms_components (0.10.4) is not yet updated for this change, so you have to stick to an older version of WTForms (2.2.1)

    EDIT : This is corrected by the version 2.3.1 of WTForms with a DeprecationWarning (Thanks to davidism and azmeuk for their quick reaction).
    So you just have to update to WTForms 2.3.1 .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search