令人讨厌的 CryptographyDeprecationWarning 因为到处都缺少 hmac.compare_time 函数 [英] Obnoxious CryptographyDeprecationWarning because of missing hmac.compare_time function everywhere
问题描述
事情进展顺利,直到我的一个项目开始在任何地方打印此文件,在每次执行的顶部,至少一次:
Things were running along fine until one of my projects started printing this everywhere, at the top of every execution, at least once:
local/lib/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
我不知道它为什么开始,并且它会中断应用程序/工具的输出,尤其是当它被其他工具捕获和使用时.就像整个时间里的许多困难一样,我相当肯定它与 urllib
以及相关联的 requests
相关.更糟糕的是,我有太多的项目和交叉依赖,我不可能通过调用 warnings.filterwarnings()
来更新所有的导入和分支来抑制警告.
I have no idea why it started and it's disrupting the applications'/tools' output, especially when it's being captured and consumed by other tools. Like many difficulties throughout time, I'm fairly certain it is related to urllib
and, by association, requests
. Worse, I have so many projects and cross-dependencies that I can't possibly update all of the imports and branches with the call to warnings.filterwarnings()
to suppress the warning.
我有 Python 2.7.6 .显然这在 2.7.7 中消失了.只是,我有一些系统是 2.7.6,我没有看到警告.因此,某个版本中的某些内容可能会或可能不会禁用它们,而我可能无意中将其替换为另一个版本.
I have Python 2.7.6 . Apparently this goes away in 2.7.7 . Only, I have some systems that have 2.7.6 where I do not see the warnings. So, something may or may not be disabling them in one version and I might've inadvertently replaced it with another version.
我的 Ubuntu、Python、urllib、请求(带有安全选项)、加密和 hmac 在打印警告的系统和不打印警告的系统上都是相同的版本/构建.
My Ubuntu, Python, urllib, requests (with the security option), cryptography, and hmac are all identical versions/builds on systems that do print the warning and systems that do not.
网上似乎没有相关的警告或公告,而且目前似乎任何相关项目都是静态/稳定的(即使hmac"可以通过 PIP 安装,但它已经八年没有改变了).
There appears to be no relevant warnings or announcements online and it seems like any related project is static/stable by this point (even though 'hmac' can be installed via PIP, it hasn't changed in eight years).
推荐答案
我遇到这个错误已经有一段时间了.对于我的环境,将 Python 升级到高于 2.7.6 的版本很痛苦.更简单的解决方案是使用 pip 降级加密模块:
I hit this error for quite sometime. For my environment, it was a pain to upgrade Python to a higher version than 2.7.6. The easier solution was to downgrade cryptography module using pip:
pip2.7 install cryptography==2.2.2
我认为最好的解决方案是升级你的python版本
I think the best solution is to upgrade your python version though
这篇关于令人讨厌的 CryptographyDeprecationWarning 因为到处都缺少 hmac.compare_time 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!