Docker Django: underlying buffer has been detached [How to Solve]

#error:underlying buffer has been detached
#Envirment: Docker, Django3.2.5, pyhton3.6

Scenario: the above error occurs every time I execute Python 3 runserver

Finally, the problem was that I introduced the following code into some Python files

sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach())  # System current default encoding format

​However, this code is a habitual way of writing the default output code in Python 2.

Solution: delete all sys.stdout in the .Py file


Similar Posts: