2

I am very new to cx_Freeze, but when I tried to use pyHooks, it didn't work. here's my setup.py code:

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]
)

and when I run the exe file, the error says:

ImportError: cannot import name cpyHook

CannedAnchovy
  • 308
  • 1
  • 2
  • 7
  • Can you show the output from when you freeze it? It will be quite long, so put it in a pastebin. – Thomas K Oct 14 '13 at 00:27
  • never mind, I fixed it by putting the pyHook folder in the same folder as the exe file. – CannedAnchovy Oct 14 '13 at 11:00
  • 1
    Could you explain in more detail what you did? When I freeze my app with cxFreeze I have pyHook folder in the same folder as exe. It even has _cpyHook.pyd file in it. But I still get the same error as you. – ragezor Mar 20 '17 at 21:07

1 Answers1

2

Ok so one workaround is to manually include cpyHook.py.

options = {"build_exe": {"includes":includes, 'include_files': ['cpyHook.py']}},

You can get cpyHook.py in <python install dir>\Lib\site-packages\pyHook\

ragezor
  • 360
  • 1
  • 4
  • 16