我一直在尝试运行一个简单的烧瓶应用程序,但我收到以下错误。
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
我正在运行它作为python app.py,sudo python app.py但是同样的错误总是弹出
Traceback (most recent call last):
File "app.py", line 1, in <module>
from flask import Flask
File "/usr/local/lib/python2.7/site-packages/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/usr/local/lib/python2.7/site-packages/werkzeug/__init__.py", line 152, in <module>
__import__('werkzeug.exceptions')
File "/usr/local/lib/python2.7/site-packages/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 26, in <module>
from werkzeug.http import HTTP_STATUS_CODES, \
File "/usr/local/lib/python2.7/site-packages/werkzeug/http.py", line 26, in <module>
from urllib2 import parse_http_list as _parse_list_header
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1230, in <module>
import ssl
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 133, in <module>
PROTOCOL_SSLv23 = PROTOCOL_TLS
NameError: name 'PROTOCOL_TLS' is not defined
感谢帮助,谢谢!
答案 0 :(得分:1)
完全卸载了python及其所有依赖项并且它有效。
答案 1 :(得分:0)
当您拥有过时的OpenSSL或PyOpenSSL版本时,似乎会发生此错误。更新PyOpenSSL应该可以解决这个问题:
pip install --upgrade pyopenssl