Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError on Windows - encoding / charmap problem #310

Closed
pyinstaller-tickets-migration opened this issue Oct 18, 2014 · 1 comment
Assignees
Labels

Comments

@pyinstaller-tickets-migration

Original date: 2012/01/22

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

@matysek
Copy link
Member

matysek commented Oct 18, 2014

Original date: 2013/03/19

This is the issue of the python itself in the windows console. If you will run that code with python directly from windows console you will get the same error.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants