我得到一个UnicodeEncodeError打印从我的应用程序Unicode字符串时的错误.它通过AWS上的Elastic Beanstalk运行(Apache + mod_wsgi).我发现这非常有用,当我打电话locale.getdefaultlocale()和locale.getpreferredencoding()我得到的None和ASCII.
我设置LANG和LC_ALL对en_US.UTF-8(通过WSGIDaemonProcess指令和环境变量).现在,当我打电话locale.getdefaultlocale()和locale.getpreferredencoding()我得到('en_US', 'UTF-8')和UTF-8.但是,我仍然是一样的UnicodeEncodeError.
sys.stdout是类型的mod_wsgi.Log.我找不到有关如何检查/设置此编码的任何细节.
我不知道如何继续调试.我该如何解决这个错误?
这个wsgi.conf是Elastic Beanstalk的默认设置,除了我添加的地方lang和localeWSGIDaemonProcess指令.
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/python/run/baselinenv
WSGISocketPrefix run/wsgi
WSGIRestrictEmbedded On
<VirtualHost *:80>
Alias /static/ /opt/python/current/app/static/
<Directory /opt/python/current/app/static/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /opt/python/current/app/application.py
<Directory /opt/python/current/app/>
Require all granted
</Directory>
WSGIDaemonProcess wsgi processes=1 threads=15 …Run Code Online (Sandbox Code Playgroud)