Home > Mobile >  ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security'
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security'

Time:03-30

any ideas why this error?

my project was working fine, i copied it to an external drive and onto my laptop to work on the road, it worked fine. i copied back to my desktop and had a load of issues with invalid interpreters etc, so i made a new project and copied just the scripts in, made a new requirements.txt and installed all the packages, but when i run i get this error

Traceback (most recent call last):
  File "E:\Dev\spot_new\flask_blog\run.py", line 1, in <module>
    from flaskblog import app
  File "E:\Dev\spot_new\flask_blog\flaskblog\__init__.py", line 3, in <module>
    from flask_bcrypt import Bcrypt
  File "E:\Dev\spot_new\venv\lib\site-packages\flask_bcrypt.py", line 21, in <module>
    from werkzeug.security import safe_str_cmp
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' (E:\Dev\spot_new\venv\lib\site-packages\werkzeug\security.py)

i've tried uninstalling python, anaconda, pycharm, deleting every reg key and environment variable i can find that looks pythonic, reinstalling all from scratch but still no dice.

any input greatly appreciated!

thanks

CodePudding user response:

Werkzeug released v2.1.0 today, removing werkzeug.security.safe_str_cmp.

You can probably resolve this issue by pinning Werkzeug~=2.0.0 in your requirements.txt file (or similar).

  • Related