Reputation: 197
I am using pyinstaller
to convert .py
to .exe
however after converting, when I then run the .exe
, a command line window pops up for a split second and closes. the .exe isn't working almost at all, I then navigate to the warn.txt
file and it says that there are a bunch of missing modules:
missing module named resource
missing module named posix
missing module named _posixsubprocess
missing module named cv2
and allot more (24 in total)
I've researched this problem and could not get a good answer iv tried converting with --onefile
and --onedir
and the same thing happens.
how do I import or fix these missing modules so that the .exe
will run correctly or even at all?
Upvotes: 2
Views: 5214
Reputation: 482
Try to make a spec file and use hidden_imports for the modules you are missing:
# -*- mode: python -*-
import sys
sys.setrecursionlimit(5000)
block_cipher = None
a = Analysis(['src\\main.py'],
pathex=['your_path_text'],
binaries=[],
datas=[],
hiddenimports=['cv2','your_missing_modules...'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='main',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='main')
Then run pyinstaller main.spec
.
Upvotes: 1