Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py2exe: error: libzmq.pyd: No such file or directory

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

like image 512
Mads M Pedersen Avatar asked Feb 14 '13 08:02

Mads M Pedersen


3 Answers

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__,))
    ]
)
like image 83
Nikita Nemkin Avatar answered Sep 22 '22 03:09

Nikita Nemkin


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.

like image 3
jbmohler Avatar answered Sep 21 '22 03:09

jbmohler


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

like image 1
Mads M Pedersen Avatar answered Sep 22 '22 03:09

Mads M Pedersen