gwg*_*gwg 10 python flask python-2.7
在Windows中,当我遇到以下错误时,我正在关注此Flask教程:
C:\Users\Gregory Gundersen\Documents\Research\flask-test>python run.py
Traceback (most recent call last):
File "run.py", line 2, in <module>
from app import app
File "C:\Users\Gregory Gundersen\Documents\Research\flask-test\app\__init__.py
", line 1, in <module>
from flask import Flask
File "C:\Python27\lib\site-packages\flask\__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "C:\Python27\lib\site-packages\flask\app.py", line 26, in <module>
from . import json
File "C:\Python27\lib\site-packages\flask\json.py", line 25, in <module>
from itsdangerous import json as _json
File "C:\Python27\lib\site-packages\itsdangerous.py", line 14, in <module>
import hmac
File "C:\Python27\lib\hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
Run Code Online (Sandbox Code Playgroud)
有SO问题和答案,但它们适用于OS X/Django.之前有没有人为PC/Flask看过或解决过这个问题?
Mar*_*ers 14
您似乎对问题21306进行了一半更改(将hmac.compare_digest向后移植到2.7).
你的hmac模块有以下几行:
from operator import _compare_digest as compare_digest
Run Code Online (Sandbox Code Playgroud)
在顶部,但你的sys.version_info节目你运行Python 2.7.6; 引用我们的快速聊天会话:
我:下一个简单的检查:
Run Code Online (Sandbox Code Playgroud)import sys print(sys.version_info)您:
sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
但是,hmac您拥有的版本适用于Python 2.7.7及更高版本!
你想要重新安装你的Python; 下载2.7.8并重新安装它以确保您的标准库文件具有正确的二进制可执行文件.
| 归档时间: |
|
| 查看次数: |
15612 次 |
| 最近记录: |