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

AttributeError: module 'hashlib' has no attribute 'scrypt' #404

Open
Maheran-blip opened this issue Nov 26, 2024 · 1 comment
Open

AttributeError: module 'hashlib' has no attribute 'scrypt' #404

Maheran-blip opened this issue Nov 26, 2024 · 1 comment

Comments

@Maheran-blip
Copy link

(venv) rayhan@Rayhans-MacBook-Air microblog % flask shell
Python 3.9.6 (default, May 7 2023, 23:32:44)
[Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
App: app
Instance: /Users/rayhan/microblog/instance

from werkzeug.security import generate_password_hash
hash = generate_password_hash('foobar')
Traceback (most recent call last):
File "", line 1, in
File "/Users/rayhan/microblog/venv/lib/python3.9/site-packages/werkzeug/security.py", line 107, in generate_password_hash
h, actual_method = _hash_internal(method, salt, password)
File "/Users/rayhan/microblog/venv/lib/python3.9/site-packages/werkzeug/security.py", line 42, in _hash_internal
hashlib.scrypt(
AttributeError: module 'hashlib' has no attribute 'scrypt'

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Nov 26, 2024

This happens because the Python that ships with macOS is missing the scrypt module.

You have two possible solutions:

  • Install a different Python, such as one from python.org or homebrew.
  • To keep using the macOS Python, you can add a method='pbkdf2' argument to the call to generate_password_hash().

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

2 participants