本文介绍了无法从hashlib导入scrypt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用标准的导入scrypt库.

在我的本地计算机(ubuntu 16.04)和服务器(heroku/heroku堆栈)上,导入均失败.

Both on my local machine (ubuntu 16.04) and the server (heroku/heroku stack) the import fails.

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

在两个系统上都安装了openssl 1.0.2g.这是一个已知问题还是我该如何解决?

On both systems openssl 1.0.2g is installed. Is this a know problem or how can I fix it?

推荐答案

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

As far as I understand it, a requirement to use scrypt is that you have OpenSSL 1.1+ installed. If you have a look at the hashlib.py:

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

您会看到,如果您没有安装正确版本的OpenSSL,则使scrypt可用的导入会顺利进行,而不会出现任何消​​息,如果发生这种情况,您当然不能使用它.也许是pypi的scrypt软件包( https://pypi.python.org/pypi/scrypt/)是您的替代选择吗?

you see that the import to make scrypt available for you just passes without any message if you don't have OpenSSL in the right version installed and of course you can't use it if that happens. Maybe the scrypt package from pypi (https://pypi.python.org/pypi/scrypt/) is an alternative for you?

这篇关于无法从hashlib导入scrypt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 19:04