我选择尝试使用 cx_freeze,它将我的简单 python 3.x 键盘记录器转换为 exe。我选择 cx_freeze 因为 py2exe 只是 python 2.x 我正在使用这个 setup.py 脚本编译我的代码。
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])
base = 'Console'
executables = [
Executable('logger.py', base=base, targetName = 'logger.exe')
]
setup(name='PyLogger',
version = '0.1',
description = 'A Simple Keylogger',
options = dict(build_exe = buildOptions),
executables = executables)
当我编译我的代码时
try:
import pythoncom
except ImportError:
input("Import Error, pywin32 is not installed")
try:
import pyHook
except ImportError:
input("Import Error, pyHook is not installed")
我收到导入错误,提示未安装 pywin32 和 pyHook。如何将外部模块导入 cx_freeze。
编辑 - 我尝试更改 setup.py 以添加包含选项,但没有任何区别。
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ['pyHook','pythoncom'],includes = ['pyHook','pythoncom'], excludes = [])
base = 'Console'
executables = [
Executable('logger.py', base=base, targetName = 'logger.exe')
]
setup(name='PyLogger',
version = '0.1',
description = 'A Simple Keylogger',
options = dict(build_exe = buildOptions),
executables = executables)