2016-12-12 32 views
0

我想使用Bcrypt模塊。我有這個快速測試的目的,具體如下:Python Bcrypt只能在Python中使用Interpreter

import bcrypt 

password = b"super secret password" 

hashed = bcrypt.hashpw(password, bcrypt.gensalt()) 

if bcrypt.checkpw(password, hashed): 
    print("It matches!") 
else: 
    print("Password doesnt match") 

當試圖運行它,我收到以下錯誤:

Traceback (most recent call last): 
    File "bcrypt.py", line 1, in <module> 
    import bcrypt 
    File "/Users/Kai/playground/bcrypt.py", line 5, in <module> 
    hashed = bcrypt.hashpw(password, bcrypt.gensalt()) 
AttributeError: module 'bcrypt' has no attribute 'hashpw' 

當試圖運行此Python解釋器內WITHIN 「操場」目錄我收到相同的錯誤。

當我去我的家目錄~/和運行通過Python解釋器相同的代碼它工作完全正常 Python 3.5.2 Interpreter

我已經做了兩個pip3 install bcrypt --upgrade & pip install bcrypt --upgrade

我想找出我能做些什麼來解決這個問題,我也卸載並重新安裝了Python3。

+0

你打電話給你的文件'bcrypt.py'嗎?如果是這樣,不要。 – user2357112

回答

0

它看起來像問題是你的文件和庫文件被稱爲相同。

相關問題