Python Forum
Problem with Flask Bcrypt import module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Flask Bcrypt import module
#1
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:
Reply
#2
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.
Reply
#3
Just solved!
I didn't add the following part of code

bcrypt = Bcrypt(app)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with memory_graph module akbarza 3 296 Mar-04-2024, 10:15 AM
Last Post: snippsat
  problem using coloeama module akbarza 3 512 Jan-08-2024, 07:31 AM
Last Post: akbarza
  Problem with flask on Mac David763 13 2,100 Dec-19-2023, 07:22 PM
Last Post: David763
  is import cointegration_analysis a recognized module mitcht33 1 384 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in using subprocess module akbarza 5 944 Sep-24-2023, 02:02 PM
Last Post: snippsat
  problem in import module from other folder akbarza 5 1,258 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using pyqrcode module to create QRcode akbarza 9 1,790 Aug-23-2023, 04:17 PM
Last Post: snippsat
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 680 Aug-06-2023, 01:09 AM
Last Post: aupres
  [WORKED AROUND] Problem installing elitech-datareader, 'cannot import build_py_2to3' NeilUK 4 1,561 Jul-09-2023, 10:01 AM
Last Post: NeilUK
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 932 May-15-2023, 02:38 PM
Last Post: tonynapoli2309

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020