无法从hashlib导入scrypt

时间:2017-07-06 19:34:58

标签: python openssl python-import scrypt

我尝试使用standard libary中的import 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 个答案:

答案 0 :(得分:1)

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

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

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