Python3 reports UnsupportedOperation when testing flask

description

Python3 reports UnsupportedOperation when testing flask

sources of topics and their own ideas

Source: install and test flask according to Section 1.6.1 of "Python3 Web Crawler Development practice"
idea: query flask documents-installation and getting started, try to find out if the problem is set up; check whether Baidu has any relevant solutions; read the documents in the error report and don"t know where the problem is.

related codes

/ /
from flask import Flask
app = Flask (_ _ name__)

@ app.route ("/")
def hello ():

return "Hello World!"

if name ="_ _ main__":

app.run()

/ /

expected results and actual seen error messages

expected result: I hope I can pass the test and use flask normally
actual error message:
Traceback (most recent call last):

File "< ipython-input-9-aa76cd996e6c >", line 10, in < module >

app.run()

File "D:Softwareanacondalibsite-packagesflaskapp.py", line 938, in run

cli.show_server_banner(self.env, self.debug, self.name, False)

File "D:Softwareanacondalibsite-packagesflaskcli.py", line 629, in show_server_banner

click.echo(message)

File "D:Softwareanacondalibsite-packagesclickutils.py", line 259, in echo

file.write(message)

UnsupportedOperation: not writable

the background of the problem: win10,python3.6

Mar.30,2021

this error should be reported when the echo executes the output file to an unwritable place.

this is a closed issue on github,
means that the following file needs to be modified:

  • change the echo function None in site-packages/click/utils.py to sys.stdout .
  • also modifies the secho function in .. / site-packages/click/termui.py .
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

Finally, I did not report this error by changing the name of the computer (originally in Chinese) to English, and I don't know why
(source: https://www.jianshu.com/p/d4e.)

if you encounter in the future, maybe you can refer to
to start reporting the error is the link, but then start Baidu and start to try those methods, but you don't know why it becomes the wrong one I mentioned

.

Thank you, boss ~

Menu