Forums

import error: ImportError: cannot import name '_request_ctx_stack' from 'flask'

Hello,

I'm seeing the following error, and I'm at a loss as to how to resolve it.

ImportError: cannot import name '_request_ctx_stack' from 'flask' (/home/kpuln/.local/lib/python3.10/site-packages/flask/__init__.py)

As I'd like to use Sessions with my Flask app, I did a "pip install Flask-Session" in the bash console, and then a "pip unistall Flask-Session" after receiving the above error.

Any suggestions?

Thanks in advance...

kpuln

Maybe installing FlaskSession upgraded the version of Flask to an incompatible version? Try pip install --upgrade Flask==2.1.2

Thank you, your suggestion was very helpful. However, it did produce the following errors:

- ImportError: cannot import name 'url_quote' from 'werkzeug.urls' 
and then
- ImportError: cannot import name 'parse_rule' from 'werkzeug.routing'

To resolve both of these new errors, I had to use:

pip install Werkzeug==2.1.2

Thanks

Glad you got that working!