<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Just for the archives…</div><div class="">To workaround this, I changed my Python Logging configuration:</div><div class="">from<span class="Apple-tab-span" style="white-space:pre">   </span>:<span class="Apple-tab-span" style="white-space:pre">   </span>logging.basicConfig(filename=APP_LOG_PATH, level=logging.DEBU…..</div><div class="">to<span class="Apple-tab-span" style="white-space:pre"> </span>:<span class="Apple-tab-span" style="white-space:pre">   </span>logging.basicConfig(handlers=[logging.FileHandler(filename=APP_LOG_PATH, encoding='utf-8')], level=logging.DEBU…...</div><div class="">With the explicit encoding parameter, UTF-8 characters are now logged without complaint.</div><div class=""><br class=""></div><div class="">During investigation, I dumped os.environ in the different launching contexts and noticed:</div><div class="">- When launched from PyCharm, PYTHONIOENCODING and LC_CTYPE are set to “UTF-8” and “en_US.UTF-8” respectively.</div><div class="">- When invoked by launching .app/Contents/MacOS/<binary> from the Terminal.app, LANG is set to "en_GB.UTF-8”.</div><div class="">- When launched by pyqtdeploy, LANG is set to "en_GB.UTF-8” (perhaps unsurprisingly, as pyqtdeploy was itself launched from Terminal.app and presumably confers its environment onto the binary it makes and launches).</div><div class="">- When the app is just double-clicked, however, no environment variables are set relating to any of PYTHONIOENCODING, LC_CTYPE or LANG.   I see that __CF_USER_TEXT_ENCODING is set but I don’t think Python is particularly wowed by this.</div><div class=""><br class=""></div><div class="">I checked pyqtdeploy_start.cpp.  </div><div class="">locale_codec_name is "UTF-8” (which is good).  </div><div class="">I also hacked-in  Py_SetStandardStreamEncoding("UTF-8", "strict”);   just before  <span style="color: rgb(192, 192, 192);" class="">    </span>Py_Initialize();   but this had no discernible effect.</div><div class=""><br class=""></div><div class="">I wonder if the lack of 'LANGUAGE', 'LC_ALL', 'LC_CTYPE' or ‘LANG’ is causing Python to fall back on a more primitive encoding...</div><div class=""><br class=""></div><div class="">locale.getdefaultlocale()  consistently returns None, None.</div><div class=""><br class=""></div><div class="">Possibly of interest:</div><div class="">- <a href="https://docs.python.org/2/library/locale.html#locale.getdefaultlocale" class="">https://docs.python.org/2/library/locale.html#locale.getdefaultlocale</a></div><div class="">- <a href="http://stackoverflow.com/questions/25661295/why-does-qcoreapplication-call-setlocalelc-all-by-default-on-unix-linux" class="">http://stackoverflow.com/questions/25661295/why-does-qcoreapplication-call-setlocalelc-all-by-default-on-unix-linux</a></div><div class=""><br class=""></div><div class="">Anyway I’m just sending this into the ether so maybe it can sit in the archives and possibly help someone else one day…</div><div class="">— Dave.</div><div class=""><br class=""></div><br class=""></body></html>