Ticket #310 (closed defect: invalid)
UnicodeEncodeError on Windows - encoding / charmap problem
|Reported by:||fruehwir||Owned by:|
|Severity:||normal||Keywords:||encoding, codec, charmap, unicode, utf-8, windows, stdout|
Description (last modified by htgoebel) (diff)
The execution of following code:
print u'confusing cat: \u0283i-wa\u0127\u0259d'
fails with an UnicodeEncodeError? when compiled with pyInstaller-1.5-rc1 on Windows XP SP3. The full traceback:
Traceback (most recent call last): File "<string>", line 1, in <module> File ".\pyInstallerUnicodeIssue\build\pyi.win32\pyInstallerUnicodeIssue\outPYZ1.pyz/encodings.cp850", line 12, in encode UnicodeEncodeError: 'charmap' codec can't encode character u'\u0283' in position 15: character maps to <undefined>
It seems that the environment variable PYTHONIOENCODING has to be set somewhere in the Makespec/Build? process. I tried to set it manually to "utf_8" at build and execution time and the error was gone. But: By now I wasn't able to reproduce it.
Also the following hack at the beginning of the module worked for me:
import sys import codecs sys.stdout = codecs.getwriter('utf8')(sys.stdout)
Although it seems at first that the error only occurs in context of stdout I had the same problems with third-party libraries too.
See also this thread on the mailing list:
- Owner changed from giovannibajo to matysek
- Status changed from new to assigned
- Owner matysek deleted
- Status changed from assigned to new
- Milestone changed from PyInstaller 2.0 to PyInstaller 2.1