Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Flask UnsupportedOperation: not writable

Tags:

python

flask

When I run the following code, I get the error message: "UnsupportedOperation: not writable":

from flask import Flask

app_flask = Flask(__name__)

@app_flask.route('/')
def hello_method():
    return "Hello, main page!"

if __name__ == '__main__':
    app_flask.run()

Can anyone offer some guidance? I know there's another question like this one, but the answers were not helpful at all. Here's the rest of the error message:

Traceback (most recent call last):

  File "<ipython-input-13-a122d150300b>", line 20, in <module>
    app_flask.run()

  File "C:\anaconda3\lib\site-packages\flask\app.py", line 938, in run
    cli.show_server_banner(self.env, self.debug, self.name, False)

  File "C:\anaconda3\lib\site-packages\flask\cli.py", line 629, in show_server_banner
    click.echo(message)

  File "C:\anaconda3\lib\site-packages\click\utils.py", line 259, in echo
    file.write(message)

UnsupportedOperation: not writable
like image 244
Sean McCarthy Avatar asked Dec 23 '22 06:12

Sean McCarthy


2 Answers

I found the answer here, courtesy of josechval: https://github.com/plotly/dash/issues/257

Jose says: "You need to edit the "echo" function definition at ../site-packages/click/utils.py . The default value for the "file" parameter must be sys.stdout instead of None. Do the same for the "secho" function definition at ../site-packages/click/termui.py"

like image 97
Sean McCarthy Avatar answered Dec 25 '22 18:12

Sean McCarthy


Another solution from the same issue already quoted:

Downgrade flask:

conda install flask=0.12.2

like image 29
nocibambi Avatar answered Dec 25 '22 19:12

nocibambi