Problem with Flask Bcrypt import module - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Problem with Flask Bcrypt import module (/thread-29398.html) |
Problem with Flask Bcrypt import module - marcello86 - Aug-31-2020 Hi there I need urgent help I have been stuck on this for days now, in my code I need to use the function generate_password_hash which is in bcrypt but returns the following error: AttributeError: 'module' object has no attribute 'generate_password_hash' Anyone has any idea? what's wrong? in my code I import the following: from flask import Flask from flask_bcrypt import bcrypt then in the code I use the function as following in a class: class User(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(64), unique=True) pwd = db.Column(db.String(128)) def __init__(self,username,pwd): self.username=username self.pwd=bcrypt.generate_password_hash(pwd) I checked and bcrypt is installed under venv environment pip show flask-bcrypt Name: Flask-Bcrypt Version: 0.7.1 Summary: Brcrypt hashing for Flask. Home-page: https://github.com/maxcountryman/flask-bcrypt Author: Max Countryman Author-email: [email protected] License: BSD Location: /home/itad/DICP_evo_dev/venv/lib/python2.7/site-packages Requires: bcrypt, Flask Required-by: RE: Problem with Flask Bcrypt import module - bowlofred - Aug-31-2020 Make sure you don't have a file in your space that conflicts with one of the module names (like a file called 'bcrypt.py' or 'flask_bcrypt'.py). That can prevent the actual module from loading. RE: Problem with Flask Bcrypt import module - marcello86 - Aug-31-2020 Just solved! I didn't add the following part of code bcrypt = Bcrypt(app) |