Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'import_string' from 'werkzeug' #205

Open
aaronjolson opened this issue Jul 23, 2020 · 3 comments
Open

ImportError: cannot import name 'import_string' from 'werkzeug' #205

aaronjolson opened this issue Jul 23, 2020 · 3 comments

Comments

@aaronjolson
Copy link

I am trying to run my app, getting an error

ImportError: cannot import name 'import_string' from 'werkzeug'

The error is from

venv/lib/python3.7/site-packages/flask_cache/__init__.py", line 24, in <module>
    from werkzeug import import_string

I am running Python 3.7

pip freeze says
Werkzeug==1.0.1
Flask==1.1.1
Flask-Cache==0.13.1
redis==3.5.3

Anyone else run into this error? Anyone know of a fix?

@touilleMan
Copy link

For anyone stumbling into this issue, here is the quick'n dirty way to solve this:

# Monkeypatch to fix import in flask-cache
from werkzeug.utils import import_string
import werkzeug
werkzeug.import_string = import_string

import flask_cache  # Obviously flask_cache must be imported after the monkeypatch

@tuanardouin
Copy link

Or if you're like me and a bit tired, check your virtual env.

@chandukiran13
Copy link

@tuanardouin can you please add more on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants