To do a test using @
metulburr pong example
here.
Build in a virtual environment,so all install of Pygame and Pyinstaller is new.
Full run:
# Make environment E:\div_code λ python -m venv pygame_env # Cd in E:\div_code λ cd pygame_env\ # Activate environment E:\div_code\pygame_env λ E:\div_code\pygame_env\Scripts\activate # Install (pygame_env) E:\div_code\pygame_env λ pip install pygame pyinstaller Collecting pygame ..... Successfully installed altgraph-0.17 future-0.18.2 pefile-2019.4.18 pygame-1.9.6 pyinstaller-3.6 pywin32-ctypes-0.2.0 # Build with Pyinstaller (pygame_env) E:\div_code\pygame_env λ pyinstaller --onefile pong.py 148 INFO: Python: 3.7.3 149 INFO: Platform: Windows-10-10.0.18362-SP0 ..... 14637 INFO: Appending archive to EXE E:\div_code\pygame_env\dist\pong.exe 14679 INFO: Building EXE from EXE-00.toc completed successfully. # Cd to dist (pygame_env) E:\div_code\pygame_env λ cd dist # List files use dir for cmd (pygame_env) E:\div_code\pygame_env\dist λ ls pong.exe* # Test run and it work (pygame_env) E:\div_code\pygame_env\dist λ pong pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html side wall hit, time to reset ball and give points
So it works,for more advance games with a addition data file like image/sound ect... may need to add this in build process.
Pyinstaller has good documentation about this.
Example on how that would look:
pyinstaller --onefile --icon=sound.ico --add-data shoot.png;. pong.py
For more addition can also use
spec file that Pyinstaller create on every run.