python bcrypt问题,未找到模块

2 投票
1 回答
1929 浏览
提问于 2025-04-18 06:29

我已经安装了 py-bcrypt 和 bcrypt。

import bcrypt
from eve import Eve
from eve.auth import BasicAuth

password = u'password'
password_hashed = bcrypt.hashpw(password, bcrypt.gensalt())
print password_hashed

File "/var/www/eve2/bcrypt.py", line 19, in <module>
password_hashed = bcrypt.hashpw(password, bcrypt.gensalt())
AttributeError: 'module' object has no attribute 'hashpw'

1 个回答

3

你需要把你的文件改个名字,不能叫 bcrypt.py。现在,你的脚本正在试图导入它自己。

撰写回答