Comments you submit will be routed for moderation. If you have an account, please log in first.
Modify

Ticket #310 (closed defect: invalid)

Opened 2 years ago

Last modified 2 months ago

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:1 Changed 2 years ago by matysek

  • Milestone set to PyInstaller 1.6

comment:2 Changed 2 years ago by matysek

  • Priority changed from normal to high

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

comment:5 Changed 16 months ago by htgoebel

  • Description modified (diff)

comment:6 Changed 16 months ago by htgoebel

  • Description modified (diff)

comment:7 Changed 16 months ago by htgoebel

  • Description modified (diff)

comment:8 Changed 14 months ago by matysek

  • Milestone changed from PyInstaller 2.0 to PyInstaller 2.1

comment:9 Changed 2 months ago by matysek

  • Priority changed from high to normal
  • Status changed from new to closed
  • Resolution set to invalid

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.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.