开发者

Lookup Error after packaging python script with py2exe

I have written a python script which binds to a socket like this:

from socket import *
addr = (unicode(), 11111)
mySocket = socket(AF_INET, SOCK_STREAM)
mySocket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
mySocket.bind(addr)

I package this script with py2exe using setup.py with the following options:

setup(
    console=["myProgram.py"],
    options = {"py2exe": {"compressed": 1,
            开发者_开发百科          "optimize": 2,
                      "bundle_files": 1,
                      "excludes": ["w9xpopen.exe"],
                      "packages": ["encodings","codecs"],
                          }},
    zipfile = None)

Under Python 2.5 this works fine. However, when I package the source under python 2.6, I get the following error:

   Traceback (most recent call last):
   File "Mod_CommsServ.pyo", line 201, in __init
    File "<string>", line 1, in bind
    LookupError: unknown encoding: idna

As you can see, I already included encodings for py2exe, but the executable still is not able to resolve 'idna'. Can anybody help me?


Because you pass a unicode string as hostname, python2.6 assumes "IDNA" (Internationalized Domain Names in Applications) needs to take place.

Just use

addr = ('', 11111)

in stead, unless you have very good reasons to require IDNA support.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜