我是 cx_Freeze 的新手,但是当我尝试使用 pyHooks 时,它不起作用。 这是我的 setup.py 代码:
from cx_Freeze import setup, Executable
includes=["re", "pyHook"]
exe = Executable(
script="hello.py",
base="Win32Gui",
targetName = "hello.exe"
)
setup(
name = "hello",
version = "1",
description = "description",
options = {"build_exe": {"includes":includes}},
executables = [exe]
)
当我运行 exe 文件时,错误显示:
ImportError: 无法导入名称 cpyHook
请您参考如下方法:
好的,一种解决方法是手动包含 cpyHook.py .
options = {"build_exe": {"includes":includes, 'include_files': ['cpyHook.py']}},
可以得到cpyHook.py在 <python install dir>\Lib\site-packages\pyHook\
