Python 3 with Flask runtime error: "AttributeError: module 'hmac' has no attribute 'digest'" on Linux but not Windows

Python 3 with Flask runtime error: "AttributeError: module 'hmac' has no attribute 'digest'" on Linux but not Windows

在我的 Ubuntu VPS 上使用时,我的 python3 flask+connexion 服务器上出现错误消息 "AttributeError: module 'hmac' has no attribute 'digest'",但我的 Windows 上没有10 件。两者都在使用 Python3,并且我已经从 CentOS 重新映像了 VPS,以防我犯了一些配置错误。

我正在尝试使用 Python3 内置 hmac 模块的摘要方法(注意 Python2 hmac 没有摘要),并且已经升级了 python 和点子。 我开始怀疑 flask 是否用它自己的实现覆盖了 hmac,但我不确定 OS 会如何影响它。任何帮助将不胜感激,干杯。

移动我的评论作为答案,以便正确回答问题。很明显,OP 使用不同的 python3 版本。

module-level hmac.digest() is new in 3.7. So it's not available in 3.5. In 3.5 you can the digest method of HMAC object. I would guess on Windows you have the latest 3.7 installed.