UnicodeEncodeError [Python3/Gunicorn/Nginx/Django]

流过昼夜 提交于 2019-12-05 12:31:06

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!