繁体   English   中英

Pywhatkit 和 auto-py-to-exe

[英]Pywhatkit and auto-py-to-exe

我的问题基本上是使用 pywhatkit 在 python 中创建了一个脚本,在控制台中,它工作正常,但是当我将 py 转换为 exe 并尝试发送消息时,只看到 cmd 立即打开和关闭,没有任何反应。 我还在应用程序中进行了调试,但没有任何显示

发生这种情况是因为您的pywhatkit依赖项未添加到.EXE文件中。 您应该打开projectname.spec文件并编辑以下行:

# -*- mode: python ; coding: utf-8 -*-
**from PyInstaller.utils.hooks.import collect_submodules**

block_cipher = None
**hidden_imports= collect_submodules('pywhatkit')**


a = Analysis(
    ['mine.py'],
    pathex=[],
    binaries=[],
    datas=[],
    **hiddenimports=hidden_imports,**
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='mine',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

保存文件后,您应该像以前的文件一样运行此文件。

pyinstaller --onefile projectname.spec

就像你必须安装所有依赖项一样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM