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 generate_password_hash #94

Open
DarioAmiri opened this issue Aug 28, 2021 · 3 comments
Open

ImportError: cannot import name generate_password_hash #94

DarioAmiri opened this issue Aug 28, 2021 · 3 comments

Comments

@DarioAmiri
Copy link

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.

@DarioAmiri
Copy link
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.

@sequc82
Copy link

sequc82 commented Jan 25, 2023

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?

@sequc82
Copy link

sequc82 commented Feb 1, 2023

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants