在Flask中执行app.run(debug = True)行时出错

时间:2018-09-29 01:42:53

标签: python python-3.x flask

这是我的代码。

from flask import Flask
app=Flask(__name__)

@app.route('/')
def home():
    return "WebApp"

if __name__=="__main__":
    app.run(debug=True)

这是我遇到的错误。

Traceback (most recent call last):
File "F:/Python Projects/webapp1.py", line 7, in <module>
    app.run(debug=True)
File "C:\Program Files\Python36\lib\site-packages\flask\app.py", line 938, in run
    cli.show_server_banner(self.env, self.debug, self.name, False)
File "C:\Program Files\Python36\lib\site-packages\flask\cli.py", line 629, in show_server_banner
    click.echo(message)
File "C:\Program Files\Python36\lib\site-packages\click\utils.py", line 218, in echo
    file = _default_text_stdout()
File "C:\Program Files\Python36\lib\site-packages\click\_compat.py", line 675, in func
    rv = wrapper_func()
File "C:\Program Files\Python36\lib\site-packages\click\_compat.py", line 436, in get_text_stdout
    rv = _get_windows_console_stream(sys.stdout, encoding, errors)
File "C:\Program Files\Python36\lib\site-packages\click\_winconsole.py", line 295, in _get_windows_console_stream
    func = _stream_factories.get(f.fileno())
io.UnsupportedOperation: fileno

我是Flask的新手,目前对此知识很少。感谢您的回答!

1 个答案:

答案 0 :(得分:1)

这是 click 软件包issue 1021的错误。

您可以通过在Shell中运行而不是在python idle中运行来避免这种情况。