Ticket #310 (closed defect: invalid)
UnicodeEncodeError on Windows - encoding / charmap problem
| Reported by: | fruehwir | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | PyInstaller 2.1 |
| Component: | PyInstaller | Version: | |
| Severity: | normal | Keywords: | encoding, codec, charmap, unicode, utf-8, windows, stdout |
| Cc: |
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:
http://groups.google.com/group/pyinstaller/browse_thread/thread/7bad082b306a0ea6/4164cdac4d926468
Attachments
Change History
comment:3 Changed 2 years ago by matysek
- Owner changed from giovannibajo to matysek
- Status changed from new to assigned
comment:4 Changed 20 months ago by matysek
- Owner matysek deleted
- Status changed from assigned to new
