【问题标题】:Can not import scrypt from hashlib无法从 hashlib 导入 scrypt
【发布时间】:2017-12-10 23:10:39
【问题描述】:

我尝试使用来自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。这是一个已知问题还是我该如何解决?

【问题讨论】:

    标签: python openssl python-import scrypt


    【解决方案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 包是你的替代方案?

    【讨论】:

    • 如前所述 openssl 1.0.2 已安装。
    • 是的,但您需要 OpenSSL 的版本 >= 1.1
    猜你喜欢
    • 2019-08-17
    • 2011-09-27
    • 2019-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    • 2019-05-27
    相关资源
    最近更新 更多