Unicode problem... arises with py2exe

Martyn Quick mrq at for.mat.bham.ac.uk
Thu Feb 13 06:52:33 EST 2003


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!?!

As a further question - I feel all at sea with unicode strings... I've
read "Learning Python" but there is no mention of such things in there.  I
guess it's time for me to move onto a more advanced book - is "Programming
Python" appropriate?  (I am not an expert in programming in any language -
I basically learnt Python through "Learning Python" and that is about all
I know!)

Cheers,
Martyn

--------------------------------------------------------
Dr. Martyn Quick  (Research Fellow in Pure Mathematics)
University of Birmingham, Edgbaston, Birmingham, UK.
http://www.mat.bham.ac.uk/M.R.Quick/





More information about the Python-list mailing list