pythonattributeerrortraceback

error (AttributeError) problem with passlib[bcrypt] module


(trapped) error reading bcrypt version
Traceback (most recent call last):
File "C:\\Users\\User\\Desktop\\lazare\\api practice\\venv\\Lib\\site-packages\\passlib\\handlers\\bcrypt.py", line 620, in \_load_backend_mixin  
version = \_bcrypt.__about__.__version__
^^^^^^^^^^^^^^^^^
AttributeError: module 'bcrypt' has no attribute '__about__'

why that happened? i dont use about attribute at all. all i have from that module is this:

pwd_context = CryptContext(schemes = ["bcrypt"], deprecated = "auto")  
hashed_pass = pwd_context.hash(user.password)
user.password = hashed_pass 

i am learning api and now i am trying to build user registration process properly, so i want to hash the password and this happens.

interesting is that even tho the error appears, it still hashes the password and keep all the info in the database.

can any of you help me why that error happens and how to fix it

i just tried to update modules passlib and bcrypt. but i have the latest version


Solution

  • This issue is likely caused by bcrypt 4.1.x removing the about attribute, which passlib still tries to access.

    Can you check your bcrypt and passlib versions? Run:

    python -c "import bcrypt, passlib; print(bcrypt.__version__, passlib.__version__)"
    

    If bcrypt >= 4.1.0, try downgrading:

    pip install "bcrypt==4.0.1"
    

    Let me know what versions you have.