AttributeError:模块"bcrypt"没有适用于python的属性"hashpw" [英] AttributeError: module 'bcrypt' has no attribute 'hashpw' for python
问题描述
我不知道我在做什么错.请帮助
I don't know what I'm doing wrong. Please help
推荐答案
我也遇到了这个问题,并通过以下步骤找出了答案:
I ran into this issue as well and went through these steps to figure it out:
pip list
再次检查bcrypt是否在该列表中
pip list
double check that bcrypt is in that list
python --version
返回了Python 2.7.15rc1
python --version
which returned Python 2.7.15rc1
python3 --version
返回了Python 3.6.7
python3 --version
which returned Python 3.6.7
我遇到了python3无法识别bcrypt包的问题:
I had an issue where python3 doesn't recognize the bcrypt package:
python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>import bcrypt (pressed enter here)
>>>
vs
python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcrypt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bcrypt'
然后,当再次检查我的文件列表时遇到相同的问题 @ user2357112 建议并将其重命名为"bcrypt.py"我创建的文件.
then when double checking my file listing ran into the same issue @user2357112 suggested and renamed the "bcrypt.py" file I had created.
您说bcrypt.py不是文件名,所以我尝试了其他方法来重新创建并在我的pharaoh.py旁边构建了一个新的bcrypt.py文件,并重现了相同的错误.
You stated that bcrypt.py is not the name of the file so I tried something else to recreate and built a new bcrypt.py file next to my pharaoh.py and reproduced the same error.
我当前的代码:
#!/usr/bin/env python
import bcrypt
# raw_input for pv2
user = raw_input("User value: \n")
password = raw_input("password: \n")
def pass_thru_crypt(user, password):
user_password = user + password
hashed = bcrypt.hashpw(user_password, bcrypt.gensalt())
if bcrypt.checkpw(user_password, hashed):
print("Indiana Jones just *bad_word* you up, Charlie!")
else:
print("You chose... poorly")
pass_thru_crypt(user, password)
这篇关于AttributeError:模块"bcrypt"没有适用于python的属性"hashpw"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!