my problem is basically that made a script in python using pywhatkit, in the console, it works fine but then when i convert py into exe and try to send the message just see a cmd opening and closing immediately and nothing happens. I also put a debug in the application but nothing shows up
It happens because your pywhatkit
dependency not added to the .EXE
file. You should open the projectname.spec
file and edit the following lines:
# -*- 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,
)
After saving the file you should run this file like the previous file.
pyinstaller --onefile projectname.spec
like that you have to install all the dependencies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.