Flask: can't run flask demo direct with F5 (idle) after upgrade to flask1.0?

Created on 11 May 2018  路  5Comments  路  Source: pallets/flask

after upgrade to flask 1.0.2, it seems not possible to direct run even the simple demo app through direct pressing F5 within idle?

but it can still be run through command "flask run" or in shell with "python demo.py"
is this normal case after upgrade?

the python shell feedback see below:


from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run(port=80, debug=False, threaded=True)

Actual Behavior

Tell us what happens instead.

Traceback (most recent call last):
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\flasktest.py", line 9, in <module>
    app.run(port=80, debug=False, threaded=True)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 938, in run
    cli.show_server_banner(self.env, self.debug, self.name, False)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\cli.py", line 629, in show_server_banner
    click.echo(message)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\lib\site-packages\click\utils.py", line 217, in echo
    file = _default_text_stdout()
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\lib\site-packages\click\_compat.py", line 621, in func
    rv = wrapper_func()
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\lib\site-packages\click\_compat.py", line 385, in get_text_stdout
    rv = _get_windows_console_stream(sys.stdout, encoding, errors)
  File "C:\Users\dell\AppData\Local\Programs\Python\Python36\lib\site-packages\click\_winconsole.py", line 261, in _get_windows_console_stream
    func = _stream_factories.get(f.fileno())
io.UnsupportedOperation: fileno

Environment

  • Python version: python3.6.4
  • Flask version: flask1.0.2
  • Werkzeug version:

Most helpful comment

Looks like this is caused by the click package-- I'll raise an issue over there and close this one up. Thanks for catching it @aekojiang.

All 5 comments

Have you tried running it outside of IDLE?
This stackoverflow question mentioned the same error being caused by IDLE.

Yes, I can run the demo and also my other flask-apps both well through shell command "flask run" (as development server) and also "python demo.py" (as production server). It both works.
Only can't directly run it by pressing F5 in IDLE, which it used to work before flask1.0.
I've test in 2 computers after upgrade to flask1.0. The Situations are same. So I guess it may be related to the new version.

Looks like this is caused by the click package-- I'll raise an issue over there and close this one up. Thanks for catching it @aekojiang.

run the saved file. ex : pythonpractice.py

This is closed, but click is still causing this problem for me when I try to run a PyInstaller created exe as a windows service. Any solutions?

Was this page helpful?
0 / 5 - 0 ratings