utf encoding error

Mike Thompson I at dontthinkso
Wed May 4 19:41:28 EDT 2005


Timothy Smith wrote:
> hi there, this one is in relation to my py2exe saga.
> 
> when i compile a package using py2exe i get the error msg below, if i 
> just run the py files it doesn't error, so i assume pysvn is trying to 
> use something thats not being included in the build. only i have no idea 
> where to start looking.
> 
> Traceback (most recent call last):
>  File "Main.pyc", line 819, in ValidateLogin
>  File "Main.pyc", line 861, in ShowMainFrameItems
> LookupError: unknown encoding: utf-8
> 
> 
> and here is my setup.py for py2exe for good measure
> 
> from distutils.core import setup
> import py2exe
>           package_dir = ['c:\python23\reportlab', 'c:\python23\lib',
>               'Z:\Projects\PubWare\trunk\python']
>               setup(windows=[ 
> "Z:\\Projects\\PubWare\\trunk\\python\\PubWare.py"])


Py2exe has a Wiki which answers a lot of these questions. In general, 
you might find it useful to look there.

For your problem: you need to explicitly include the encodings module 
for utf8. Using static analysis Py2exe can't known to include it in the 
built exe. Something like this should work for you ...

# setup.py

from distutils.core import setup
import py2exe

explicitIncludes = [
     "encodings.utf_8",

]

opts = {
     "py2exe": {
         "includes": explicitIncludes,
#       "optimize" : 2
     }
}

setup(
     windows = ["XXXXXX.py"],
     options=opts,
)



More information about the Python-list mailing list