Hi. 

I’m running python 2.6, wx 2.8, and py2exe .6.9 on XP.  I get a unicode error in a wxpython program after py2exe, in the .exe version.  The error doesn’t occur in the .py python program.  It didn’t look like the encoding issues on this website were the same as my issue. 

 

The error code is:   ‘UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 20: ordinal not in range(128)’

 

Here’s the area of code where it’s messing up.  There’s a nested try…except loop as I was trying different things to get it to work.

try:

entry_dict[cols[index]] = str(col)        #column=value

except:

      checkfile.close()

      try:

            newstr      = ''

            bad_pos     = 0

            for char in col.encode():

                  bad_pos += 1

                  if ord(char) < 128:

                        newstr = char

            entry_dict[cols[index]] = str(col)

      except:

            entry_dict[cols[index]] = str(col[0:bad_pos] + col[bad_pos+1:])