Python/Flask error: “ImportError: cannot import name _compare_digest”

前端 未结 2 1486
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 03:19

With Windows, I am following this Flask tutorial when I came across the following error:

C:\\Users\\Gregory Gundersen\\Documents\\Research\\flask-test>pyt         


        
相关标签:
2条回答
  • 2020-12-11 04:01

    You appear to have half the changes made for issue 21306 (backporting hmac.compare_digest to 2.7).

    Your hmac module has the lines:

    from operator import _compare_digest as compare_digest
    

    at the top, but your sys.version_info shows you are running Python 2.7.6; quoting our quick chat session:

    Me: Next simple check:

    import sys
    print(sys.version_info)
    

    You: sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)

    The hmac version you have is for Python 2.7.7 and up, however!

    You'll want to reinstall your Python; download 2.7.8 and reinstall it to make sure you have the correct binary executable for your standard library files.

    0 讨论(0)
  • 2020-12-11 04:03

    This can occur when you have updated python without rebuilding your virtualenv. In this case, just regenerate your virtualenv.

    0 讨论(0)
提交回复
热议问题