Overwrite Python3 Default Encoder When Using Apache Server
Solution 1:
Read:
This explains issues around lang/locale.
You aren't using mod_wsgi daemon mode, but you should be as daemon mode is the recommended method.
- http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html
- http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#embedded-or-daemon-mode
Also go read the mod_wsgi documentation at:
Solution 2:
Python3 uses what local.getpreferredencoding
returns as the encoding when opening files in text mode. I would suggest to add some logging and log the default encoding value to check whether it is the environment that's not configured properly.
It might be that there's a hard coded encoding parameter in the code somewhere. Can you show the stacktrace of the error and the corresponding code?
Depending on the deployment mechanism, it might be that the SetEnv configuration is not passed to Python. See http://ericplumb.com/blog/passing-apache-environment-variables-to-django-via-mod_wsgi.html for mod_wsgi deployments.
Similar to what is describe in that blog post, you have to modify the inginious-webapp.production file to get and set env vars manually. This is already done in the default inginious-webapp for some variables. Here you'd have to add in particular the PYTHONIOENCODING.
If you're running in mod_wsgi deamon mode, this might help http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html, in particular the lang or locale parameters.
Post a Comment for "Overwrite Python3 Default Encoder When Using Apache Server"