python 踩坑笔记

------------

问题:AttributeError: module 'bcrypt' has no attribute '__about__'

Traceback (most recent call last):
  File "D:\anaconda3\envs\python3.12\Lib\site-packages\passlib\handlers\bcrypt.py", line 620, in _load_backend_mixin
    version = _bcrypt.__about__.__version__
              ^^^^^^^^^^^^^^^^^
AttributeError: module 'bcrypt' has no attribute '__about__'

原因:passlib 尝试读取版本(仅用于日志记录)并失败的问题,因为它正在加载 bcrypt 4.1.x 中不再存在的模块

解决方案:https://github.com/pyca/bcrypt/issues/684

# 方案1、使用日志记录配置将passlib警告静音
logging.getLogger('passlib').setLevel(logging.ERROR)

# 方案2、卸载原来的版本,安装 bcrypt==4.0.1版本

pip uninstall bcrypt
pip install bcrypt==4.0.1

------------

posted @ 2025-08-04 21:47  二月雪  阅读(78)  评论(0)    收藏  举报