0

I'm trying to distribute a python app which uses pyHook I used cx_Freeze to make a compiled binary. The orginal python project works flawlessly while in .py form. But the compiled binary from cx_freeze just terminates after giving this Traceback:

    Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pyHook\cpyHook.py", line 18, in swig_impor
t_helper
    fp, pathname, description = imp.find_module('_cpyHook', [dirname(__file__)])

  File "C:\Python34\lib\imp.py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_cpyHook'

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
    , in <module>
        exec(code, m.__dict__)
      File "WinComLog.py", line 5, in <module>
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_a
    nd_load
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_a
    nd_load_unlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
    nlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
    ackward_compatible
      File "C:\Python34\lib\site-packages\pyHook\__init__.py", line 1, in <module>
        from .HookManager import *
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_a
    nd_load
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_a
    nd_load_unlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
    nlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
    ackward_compatible
      File "C:\Python34\lib\site-packages\pyHook\HookManager.py", line 1, in <module
    >
        from . import cpyHook
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2284, in _handle
    _fromlist
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_wi
    th_frames_removed
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_a
    nd_load
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_a
    nd_load_unlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
    nlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
    ackward_compatible
      File "C:\Python34\lib\site-packages\pyHook\cpyHook.py", line 28, in <module>
        _cpyHook = swig_import_helper()
      File "C:\Python34\lib\site-packages\pyHook\cpyHook.py", line 20, in swig_impor
    t_helper
        import _cpyHook
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_a
    nd_load
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2224, in _find_a
    nd_load_unlocked
    ImportError: No module named '_cpyHook'

Clearly, it can't find _cpyHook which is a part of PyHook library. I tried a lot searching but couldn't find any useful info regarding this. How to fix this?

Amol Borkar
  • 2,321
  • 7
  • 32
  • 63

1 Answers1

1

I had the same problem.

Before you compile it, copy the _cpyHook.pyd and cpyHook.py files from "c:\PythonXX\Lib\site-packages\pyHook" to "c:\PythonXX\Lib\site-packages", then compile it and it should work.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • Thank you, I had to go page 3 of google searches to find this, works perfectly, I am going to link this to similar question that is also SO question of same thing, so in the future when people come across they will find it quicker. – andyADD Dec 27 '15 at 05:32