Unicode problem... arises with py2exe
Thomas Heller
theller at python.net
Thu Feb 13 07:17:41 EST 2003
Martyn Quick <mrq at for.mat.bham.ac.uk> writes:
> I've got some code (based on stuff previously posted here by others) that
> seems to work fine when I run the script, but as soon as I try to turn it
> into a Windows exe file using py2exe.
>
> The following code (based on code that Steffen Ries originally
> posted) causes problems:
>
> ---8<----
>
> from htmlentitydefs import entitydefs
> _u2html = {}
> for entity,val in entitydefs.items():
> if len(val) == 1:
> u = unicode(val, 'latin1')
> elif val.startwith('&#'):
> u = unichr(int(val[2:-1]))
> _u2html[u] = '&%s;' % entity
>
> ----8<----
>
> The 5th line above causes a problem in the exe file that is produced... it
> gives the following error:
>
> LookupError: no codec search functions registered: can't find encoding
>
> I've no idea what this means!?!
Quoting from the py2exe homepage:
Recent Python versions contain support for unicode, which requires the
encodings package to be included in the exe-file. This is not included
by default, and it would be very difficult for py2exe to find that
this is needed.
So if your exe-file reports errors like LookupError: no codec search
functions registered: can't find encoding or LookupError: unknown
encoding, you should advise py2exe to include this package with the
'--packages encodings' command line option.
Thomas
More information about the Python-list
mailing list