dpgaspar/Flask-AppBuilder

'_FakeStack' object has no attribute '__ident_func__'

Closed this issue · 2 comments

Environment

win 11 Python 3.8.10

Flask-Appbuilder version:
4.5.0

pip freeze output:

aliyun-python-sdk-core==2.13.36
aliyun-python-sdk-dysmsapi==2.1.2
aliyun-python-sdk-kms==2.16.2
apispec==6.6.1
async-timeout==4.0.2
attrs==23.2.0
Babel==2.15.0
bcrypt==4.0.1
beautifulsoup4==4.12.2
blinker==1.6.2
cachelib==0.9.0
certifi==2021.10.8
cffi==1.16.0
charset-normalizer==2.0.12
click==8.1.7
colorama==0.4.6
colored==1.4.3
comtypes==1.1.14
contourpy==1.0.7
coverage==6.5.0
crcmod==1.7
crypto==1.4.1
cryptography==42.0.7
cycler==0.11.0
Deprecated==1.2.14
dnspython==2.6.1
email_validator==2.2.0
et-xmlfile==1.1.0
exceptiongroup==1.0.4
Flask==2.3.3
Flask-Admin==1.6.1
Flask-AppBuilder==4.5.0
Flask-Babel==2.0.0
Flask-Caching==2.3.0
Flask-HTTPAuth==4.8.0
Flask-JSON==0.4.0
Flask-JWT-Extended==4.6.0
Flask-Limiter==3.7.0
Flask-Login==0.6.3
Flask-SQLAlchemy==2.4.0
Flask-WTF==1.2.1
fonttools==4.39.3
future==0.18.3
Gooey==1.0.8.1
greenlet==3.0.3
htmldocx==0.0.6
idna==3.3
importlib-metadata==6.8.0
importlib-resources==5.12.0
iniconfig==1.1.1
itsdangerous==2.1.2
Jinja2==3.1.2
jmespath==0.10.0
jpg2pdf==0.1.0
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.4
limits==3.13.0
lxml==4.9.2
markdown-it-py==3.0.0
MarkupSafe==2.1.3
marshmallow==3.21.3
marshmallow-sqlalchemy==0.28.2
matplotlib==3.7.1
mdurl==0.1.2
mysqlclient==2.2.4
Naked==0.1.32
natsort==8.4.0
netmiko==4.2.0
ntc_templates==4.0.1
numpy==1.24.4
opencv-contrib-python==4.7.0.72
opencv-python==4.7.0.72
openpyxl==3.0.9
ordered-set==4.1.0
orjson==3.10.5
oss2==2.18.5
packaging==22.0
pandas==2.0.3
paramiko==3.3.1
Pillow==9.1.1
pkgutil_resolve_name==1.3.10
pluggy==1.0.0
prison==0.2.1
psutil==5.9.1
py==1.11.0
pycparser==2.21
pycryptodome==3.20.0
Pygments==2.18.0
pygtrie==2.4.2
PyJWT==2.8.0
PyMySQL==1.1.0
PyNaCl==1.5.0
pyparsing==3.0.9
pyproj==3.5.0
pyserial==3.5
PySimpleGUI==4.60.4
pysolr==3.9.0
pytest==7.2.1
pytest-cov==4.0.0
pytest-datadir==1.4.1
pytest-html==3.2.0
pytest-metadata==2.0.4
python-dateutil==2.8.2
python-docx==0.8.11
pytz==2021.3
pywin32==306
PyYAML==6.0.1
redis==4.6.0
redlock-py==1.0.8
referencing==0.35.1
requests==2.27.1
rich==13.7.1
rpds-py==0.18.1
scp==0.14.5
shellescape==3.8.1
six==1.16.0
soupsieve==2.4.1
SQLAlchemy==1.4.52
SQLAlchemy-Utils==0.41.2
tesserocr @ file:///D:/dl/tesserocr-2.5.2-cp38-cp38-win32.whl
textfsm==1.1.3
tinydb==4.7.0
tk==0.1.0
tomli==2.0.1
typing_extensions==4.12.2
tzdata==2024.1
urllib3==1.26.9
Werkzeug==3.0.3
wrapt==1.16.0
WTForms==3.1.2
xhlib @ file:///D:/G/xhlib
zhconv==1.4.3
zipp==3.15.0

Describe the expected results

run demo success.

Describe the actual results

(data) PS D:\G\Flask-AppBuilder\examples\quickhowto> flask run
Traceback (most recent call last):
  File "D:\py38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\py38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\pv\data\Scripts\flask.exe\__main__.py", line 7, in <module>
  File "D:\pv\data\lib\site-packages\flask\cli.py", line 1064, in main
    cli.main()
  File "D:\pv\data\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "D:\pv\data\lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\pv\data\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\pv\data\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "D:\pv\data\lib\site-packages\click\decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "D:\pv\data\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "D:\pv\data\lib\site-packages\flask\cli.py", line 912, in run_command
    raise e from None
  File "D:\pv\data\lib\site-packages\flask\cli.py", line 898, in run_command
    app = info.load_app()
  File "D:\pv\data\lib\site-packages\flask\cli.py", line 313, in load_app
    app = locate_app(import_name, None, raise_if_not_found=False)
  File "D:\pv\data\lib\site-packages\flask\cli.py", line 219, in locate_app
    __import__(module_name)
  File "D:\G\Flask-AppBuilder\examples\quickhowto\app\__init__.py", line 11, in <module>
    db = SQLA(app)
  File "D:\pv\data\lib\site-packages\flask_sqlalchemy\__init__.py", line 715, in __init__
    self.session = self.create_scoped_session(session_options)
  File "D:\pv\data\lib\site-packages\flask_sqlalchemy\__init__.py", line 748, in create_scoped_session
    scopefunc = options.pop('scopefunc', _app_ctx_stack.__ident_func__)
AttributeError: '_FakeStack' object has no attribute '__ident_func__'

Update Flask-SQLAlchemy and you are good (2.4.0 -> 2.5.1)
following commands should do the trick

pip install --upgrade flask-sqlalchemy
pip install --upgrade flask-appbuilder

i used another fresh new virtual environment and installed flask-appbuilder and mysqlclient then works fine. not sure why sometimes in other environments pip install -U not report error but cannot run.