2017-07-06 87 views
0

我尝试使用来自standard libary的导入scrypt。无法从hashlib导入scrypt

无论是在我的本地计算机(ubuntu 16.04)还是服务器(heroku/heroku堆栈),导入都会失败。

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: cannot import name 'scrypt' 

在这两个系统上都安装了openssl 1.0.2g。这是一个知道的问题,或者我该如何解决它?

回答

1

据我所知,使用scrypt的一个要求是你已经安装了OpenSSL 1.1+。如果你看看hashlib.py:

try: 
    # OpenSSL's scrypt requires OpenSSL 1.1+ 
    from _hashlib import scrypt 
except ImportError: 
    pass 

你看,进口以使scrypt供你只是传递没有任何消息,如果你没有在的OpenSSL安装了正确的版本,当然你如果发生这种情况,不能使用它。也许从pypi(https://pypi.python.org/pypi/scrypt/)的scrypt包可以替代你吗?

+0

正如前面提到的openssl 1.0.2安装。 – R3turnz

+1

是的,但是您需要在版本> = ** 1.1 **中使用OpenSSL。 – sbhle