从瓶子导入Flask'引发了一个语法错误 - Python [英] 'from flask import Flask' throws up a syntax error - Python
本文介绍了从瓶子导入Flask'引发了一个语法错误 - Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚在Python中使用Flask(来自Flask的文档)尝试了一个简单的hello世界应用程序。我使用'pip install flask'来安装Flask。我卸载并重新安装。但问题仍然存在。
I just tried a simple hello world app in Python using Flask (From Flask's documentation). I installed Flask using 'pip install flask'. I uninstalled it and installed it again. Still, the issue persists.
代码:
Code:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
错误:
Error:
Traceback (most recent call last):
File "HelloWorld.py", line 1, in <module>
from flask import Flask
File "C:\Python32\lib\site-packages\flask\__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "C:\Python32\lib\site-packages\werkzeug\__init__.py", line 154, in <module>
__import__('werkzeug.exceptions')
File "C:\Python32\lib\site-packages\werkzeug\exceptions.py", line 111
return u'<p>%s</p>' % escape(self.description)
^
SyntaxError: invalid syntax
推荐答案
所以你需要安装一个支持的Python版本。
So you need to install a supported Python version.
这篇关于从瓶子导入Flask'引发了一个语法错误 - Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文