UnicodeEncodeError [Python3/Gunicorn/Nginx/Django] UnicodeEncodeError [Python3/Gunicorn/Nginx/Django] nginx nginx

UnicodeEncodeError [Python3/Gunicorn/Nginx/Django]


For people who are having the encoding problem with gunicorn but not using it as a daemon (for example if you run gunicorn in docker you just launch the command), and therefore, not using this configuration files:

I'm using the openpyxl library to generate a spreadsheet, and I got this error when testing it in the server in which I have the service dockerized with gunicorn. After confirming that every other encoding requirement was fine (python, system locales, etc.) it was clear that the problem was gunicorn.Everything else in the app works fine, it's only the spreadsheet exportation that throws this.

I was about to try replacing gunicorn with something else but then I realized that the problem is with file names and not with the process of generating the contents of the file.

I was naming the generated file "exportació", and just replacing it with "exportacio" made it work like a charm.

Given that I really don't need non-ascii characters in the file name, that works enough for me.