again py2exe and codecs

Thomas Heller theller at python.net
Fri Mar 5 09:53:01 EST 2004


"Achim Domma" <domma at procoders.net> writes:

> Hi,
>
> I still have problems to get cjkcodecs to work with py2exe. I added
> cjkcodecs to my setup.py like this:
>
> opts = {
>     "py2exe" : {
>         "includes" : ["encodings","encodings.*","cjkcodecs","cjkcodecs.*"],
>         "packages" : ["encodings","cjkcodecs"]
>         }
>     }
>
> After that, my distribution contains _gb2312.pyd and _big5.pyd but at
> runtime I get an unknown encoding error, if I try to use gb2312 or big5. Any
> hint?

cjkcodecs installs a cjkcodecs.pth file which includes this signle line:

  import cjkcodecs.aliases

This import seems to register the cjk codecs - import lines in pth files
are executed (in site.py).

py2exe doesn't pick up any pth file, nor does it execute things in them.
So, you have to insert the 'import cjkcodecs.aliases' line in your
script, and you should be able to build it with this:

 opts = {
     "py2exe" : {
         "packages" : ["encodings","cjkcodecs"]
         }
     }

If this works for you, feel free to write something up for the wiki ;-)

Thomas





More information about the Python-list mailing list