Tag Archives: underlying buffer has been detached error

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 manage.py runserver 0.0.0.0:8000

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

Reference: https://stackoverflow.com/questions/53533860/valueerror-underlying-buffer-has-been-detached-when-i-run-python-manager-py-mak