Skip to content

ImportError: cannot import name generate_password_hash #94

Description

@DarioAmiri

When I perform this step of the install:

cd /opt/alarmdecoder-webapp/ && python manage.py initdb

I get:

/usr/local/lib/python2.7/dist-packages/OpenSSL/crypto.py:14: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
  from cryptography import utils, x509
Traceback (most recent call last):
  File "manage.py", line 12, in <module>
    from ad2web import create_app, init_app
  File "/opt/alarmdecoder-webapp/ad2web/__init__.py", line 3, in <module>
    from app import create_app, init_app
  File "/opt/alarmdecoder-webapp/ad2web/app.py", line 18, in <module>
    from .decoder import decodersocket, Decoder, create_decoder_socket
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/decoder.py", line 35, in <module>
    from .notifications import NotificationSystem, NotificationThread
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/notifications/__init__.py", line 4, in <module>
    from .views import notifications
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/notifications/views.py", line 9, in <module>
    from ..settings import Setting
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/settings/__init__.py", line 4, in <module>
    from .views import settings
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/settings/views.py", line 44, in <module>
    from ..user import User, UserDetail
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/user/__init__.py", line 3, in <module>
    from .models import UserDetail, User, UserHistory, FailedLogin
  File "/usr/local/lib/python2.7/dist-packages/gevent/builtins.py", line 53, in __import__
    result = _import(*args, **kwargs)
  File "/opt/alarmdecoder-webapp/ad2web/user/models.py", line 5, in <module>
    from werkzeug import generate_password_hash, check_password_hash
ImportError: cannot import name generate_password_hash

Is it just a matter of changing/removing an import to fix this? Would appreciate a fix.

Activity

  1. DarioAmiri commented on Aug 28, 2021

    @DarioAmiri
    Author

    I was able to get past these errors by issuing the following commands:

    sed -i s/from werkzeug import generate_password_hash/from werkzeug.security import generate_password_hash/ /opt/alarmdecoder-webapp/ad2web/user/models.py
    sudo pip install email_validator
    sed -i s/from werkzeug import secure_filename/from werkzeug.utils import secure_filename/ /opt/alarmdecoder-webapp/ad2web/updater/views.py
    

    This should be fixed in the source though. I'll try submitting a PR later.

  2. sequc82 commented on Jan 25, 2023

    @sequc82

    I take it there has not been a PR for this? I tried resolving this as @DarioAmiri mentioned above, but it has resulted in the same error experienced by @jareep in #96. Any ideas?

  3. sequc82 commented on Feb 1, 2023

    @sequc82

    For anyone else having trouble, I resolved the subsequent error @jareep identified in #96 with the pip requirements as specified by @swaggner in #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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