pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.8k stars 1.58k forks source link

sqla-custom-inline-forms example fails with "cannot import name 'escape' from 'cgi'" #2055

Open BigBaaadBob opened 4 years ago

BigBaaadBob commented 4 years ago

Running the example gives the following error.

$ python examples/sqla-custom-inline-forms/app.py
Traceback (most recent call last):
  File "REDACTED\Documents\Python Scripts\flask-admin\examples\sqla-custom-inline-forms\app.py", line 10, in <module>
    from wtforms import fields
  File "REDACTED\miniconda3\envs\flask-admin\lib\site-packages\wtforms\__init__.py", line 11, in <module>
    from wtforms import validators, widgets
  File "REDACTED\miniconda3\envs\flask-admin\lib\site-packages\wtforms\widgets\__init__.py", line 1, in <module>
    from wtforms.widgets.core import *
  File "REDACTED\miniconda3\envs\flask-admin\lib\site-packages\wtforms\widgets\core.py", line 3, in <module>
    from cgi import escape
ImportError: cannot import name 'escape' from 'cgi' (REDACTED\miniconda3\envs\flask-admin\lib\cgi.py)

Versions:

$ python --version
Python 3.9.0
$ pip list
Package          Version
---------------- -------------------
arrow            0.17.0
Babel            2.9.0
certifi          2020.6.20
click            7.1.2
colour           0.1.5
dnspython        2.0.0
email-validator  1.1.2
Flask            1.1.2
Flask-Admin      1.5.7
Flask-BabelEx    0.9.4
Flask-SQLAlchemy 2.4.4
idna             2.10
itsdangerous     1.1.0
Jinja2           2.11.2
MarkupSafe       1.1.1
pip              20.2.4
python-dateutil  2.8.1
pytz             2020.4
setuptools       50.3.1.post20201107
six              1.15.0
speaklater       1.3
SQLAlchemy       1.3.20
SQLAlchemy-Utils 0.36.8
tablib           2.0.0
Werkzeug         1.0.1
wheel            0.35.1
wincertstore     0.2
WTForms          1.0.5

I notice that WTForms is hard-coded to version 1.0.5 in the requirements.txt file. Maybe this is fixed in latter versions of WTForms?

Edit: the example seem to run fine with WTForms 2.3.3

Diego-Hernandez-Moodys commented 2 years ago

Yeah, that happened to me too. I removed the version in requirements.txt and used pip install wtforms --upgrade