使用py2exe使用zmq

时间:2017-02-22 05:12:38

标签: python python-2.7 zeromq py2exe

我有一个使用zmq的python 2.7脚本,我正在尝试使用py2exe为它构建一个Windows可执行文件。我收到以下错误:

Traceback (most recent call last):
  File "console.py", line 4, in <module>
  File "zmq\__init__.pyc", line 34, in <module>
  File "zmq\backend\__init__.pyc", line 40, in <module>
  File "zmq\backend\__init__.pyc", line 27, in <module>
  File "zmq\backend\select.pyc", line 26, in select_backend
ImportError: No module named cython

我尝试过py2exe --includes选项,包括cython和zmq没有成功。我还尝试使用-O选项运行脚本,并将生成的.pyo文件复制到dist目录。我错过了什么?

1 个答案:

答案 0 :(得分:0)

这在我的setup.py中起到了作用

import zmq.libzmq
setup(\
    version='0.0.1',
    options = {'py2exe' : {
        'includes': [ 'zmq.backend.cython'],
        "optimize": 2,
        'packages': 'encodings'
    },
    },
    data_files=[
        ('lib', (zmq.libzmq.__file__,))
    ],
    console=['app.py'],
    scripts = [ "app.py","file1.py","file2.py","file3.cfg"],
    zipfile = 'None',
)

希望它有所帮助。