How To Fix The "warning: Hidden Import" Error Pygame._view "not Found!" After I Turned My .py Program Into .exe?
After converting my .py program to .exe, my program stops running. I get the WARNING: Hidden import information pygame._view 'not found!'. I tried to import the module but that doe
Solution 1:
Actually, I can't reproduce your error. But I had a hard time to freeze apps that uses pygame
and this should fix your problem too.
Sometimes a better way is to include your module manually. For that first, you need to exclude your module with exclude-module
and feed the module manually to the final executable with Tree
class. Also with this method, some Python libs would miss and need to be added either by hidden-import
or Tree
. For example, in here I've added xml
as Tree
and queue
as hidden-import
.
import`. Use below spec file:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['script.py'],
pathex=['C:\\Users\\Rahimi\\Desktop\\test'],
binaries=[],
datas=[],
hiddenimports=['queue'],
hookspath=[],
runtime_hooks=[],
excludes=['pygame'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
a.datas += Tree("<python_path>/Lib/site-packages/pygame/", prefix= "pygame")
a.datas += Tree("<python_path>/lib/xml/", prefix= "xml")
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='script',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
runtime_tmpdir=None,
console=True )
Remember to edit path based on your current environment. Finally, generate your executable with:
pyinstaller script.spec
Post a Comment for "How To Fix The "warning: Hidden Import" Error Pygame._view "not Found!" After I Turned My .py Program Into .exe?"