py2exe: error: libzmq.pyd: No such file or directory
Asked Answered
I

4

5

During py2exe build I get the following error:

creating python loader for extension 'win32clipboard' (C:\Python27\lib\site-packages\win32\win32clipboard.pyd -> win32clipboard.pyd)
creating python loader for extension '_rl_accel' (C:\Python27\lib\site-packages\_rl_accel.pyd -> _rl_accel.pyd)
*** finding dlls needed ***
error: libzmq.pyd: No such file or directory

Can anyone explain if I really need it, where to find it or how to exclude it.

Thanks Mads

Interdepartmental answered 14/2, 2013 at 8:43 Comment(0)
J
10

Three steps are necessary to make it work:

  • Exclude libzmq.pyd from dlls with dll_excludes option. This avoids "missing pyzmq.pyd" errors.
  • Exclude zmq.libzmq (same thing) from modules with excludes. This skips the usual .pyd renamind and proxying that py2exe does.
  • Add zmq.backend.cython explicitly with includes option, because py2exe can't see it through pyzmq backend selection code. You will get "no module named cffi" errors if you fail to do that.

Example:

import zmq.libzmq

setup(
    # ...
    zipfile='lib/library.zip',
    options={
        'py2exe': {
            'includes': ['zmq.backend.cython'],
            'excludes': ['zmq.libzmq'],
            'dll_excludes': ['libzmq.pyd'],
        }
    },
    data_files=[
        ('lib', (zmq.libzmq.__file__,))
    ]
)
Jesselton answered 20/4, 2014 at 7:7 Comment(0)
A
3

Unfortunately this isn't a nice answer, but I think it is a decent diagnosis.

The py2exe wiki is not up to date (at least I think). I believe that version 13.0.0 made a change in which libzmq.pyd replaces libzmq.dll. Py2exe's normal handling of extension modules renames this to "zmq.libzmq.pyd", but that breaks the windows dll finding since (for example) zmq.core._device.pyd links explicitly to libzmq.pyd.

This motivates an alternative ugly fix of copying zmq.libzmq.pyd to libzmq.pyd in the dist folder generated by py2exe. With this fix, my py2exe output exe runs correctly with-out import errors.

Ardeb answered 5/3, 2013 at 14:36 Comment(0)
I
1

I am not sure that this is an optimal solution but it worked for me:

  • download pyzmq from http://pypi.python.org/pypi/pyzmq
  • install the egg using easy_install
  • copy libzmq.dll from C:\Python27\Lib\site-packages\pyzmq-2.2.0.1-py2.7-win32.egg\zmq to C:\Python27\dlls\

Mads

Interdepartmental answered 14/2, 2013 at 10:51 Comment(1)
There is another solution. See here.Regretful
D
0

A simpler solution which worked, as above one solution required compiling libzmq - but I-m-lzy.

  1. Copy libzmq.pyd from C:\python27\Lib\sites-packages\zmq to c:\python27\DLLs import zmq.libzmq
  2. Have the following includes and data_files in your setup. That's it

    setup( # ... options={ 'py2exe': { 'includes': ['zmq.backend.cython'] } }, data_files=[ ('lib', (zmq.libzmq.file,)) ] )

Decrypt answered 30/9, 2017 at 11:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.