0

我正在尝试分发一个 python 应用程序,它使用pyHook我使用 cx_Freeze 来制作已编译的二进制文件。原始的 python 项目在.py形式上完美地工作。但是从 cx_freeze 编译的二进制文件在给出这个 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'

显然,它找不到_cpyHook哪个是 PyHook 库的一部分。我尝试了很多搜索,但找不到任何有用的信息。如何解决这个问题?

4

1 回答 1

1

我有同样的问题。

在编译之前,将_cpyHook.pydcpyHook.py文件从复制"c:\PythonXX\Lib\site-packages\pyHook""c:\PythonXX\Lib\site-packages",然后编译它,它应该可以工作。

于 2015-12-12T11:26:13.330 回答