Skip to content

ImportError: cannot import name '_app_ctx_stack' from 'flask'  #54

@jotelha

Description

@jotelha

CI test workflow fails with

 Traceback:
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_cli.py:4: in <module>
    import dtool_lookup_server
dtool_lookup_server/__init__.py:8: in <module>
    from flask_smorest import (
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flask_smorest/__init__.py:5: in <module>
    from .spec import APISpecMixin
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flask_smorest/spec/__init__.py:12: in <module>
    from flask_smorest.utils import prepare_response
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flask_smorest/utils.py:6: in <module>
    from flask import _app_ctx_stack
E   ImportError: cannot import name '_app_ctx_stack' from 'flask' (/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/flask/__init__.py)

and this is likely due to upgrade to flask 3

Collecting flask (from dtool-lookup-server==0.18.0->-r requirements.txt (line 1))
  Downloading flask-3.0.0-py3-none-any.whl.metadata (3.6 kB)

according to several stack overflow posts, e.g. https://stackoverflow.com/questions/77240858/how-to-fix-cannot-import-name-request-ctx-stack-from-flask

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions