Python Forum

Full Version: How to shorten the size of program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Thanks for support. could you send the output you get? namly what you did.
(Feb-22-2018, 07:30 AM)garikhgh0 Wrote: [ -> ]Thanks for support. could you send the output you get? namly what you did.
You could just try.
pip install -U pyinstaller
Then in folder of your game from cmd
pyinstaller tk_game.py --onefile --windowed --clean
I always use virtual environment with pyinstaller,
as pyinstaller don't work on my OS python which has 100's packages installed.
It also much easier to troubleshot in a isolated enviroment if errors occurs as i help other with here and here.

When i did test your code i used pipenv,but could also use venv that's build into 3.6.
Here a quick run from start.
# Make folder and cd in
C:\2
λ mkdir tk_game_env
C:\2
λ cd tk_game_env

# Install
C:\2\tk_game_env
λ pipenv install pyinstaller
Creating a virtualenv for this project…
Using base prefix 'c:\\python36'
New python executable in C:\Users\Tom\.virtualenvs\tk_game_env-_QEDJAJS\Scripts\python.exe
Installing setuptools, pip, wheel...done.
.....
Installing collected packages: pypiwin32, future, pefile, altgraph, macholib, pyinstaller
Successfully installed altgraph-0.15 future-0.16.0 macholib-1.9 pefile-2017.11.5 pyinstaller-3.3.1 pypiwin32-220

Adding pyinstaller to Pipfile's [packages]…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (9a84fe)!

# Activate folder
C:\2\tk_game_env
λ pipenv shell
Launching subshell in virtual environment. Type 'exit' to return.

# Run Pyinstaller your file is tk_game.py
# Don't worry about all "api-ms-win missing" messages
C:\2\tk_game_env
λ pyinstaller tk_game.py --onefile --windowed --clean
474 INFO: PyInstaller: 3.3.1
475 INFO: Python: 3.6.4
475 INFO: Platform: Windows-10-10.0.16299-SP0
.......
86415 INFO: Appending archive to EXE C:\2\tk_game_env\dist\tk_game.exe
86435 INFO: Building EXE from out00-EXE.toc completed successfully.

# cd to dist folder
C:\2\tk_game_env
λ cd dist

# Test game
C:\2\tk_game_env\dist
λ ls
tk_game.exe*

C:\2\tk_game_env\dist
λ tk_game.exe
Pages: 1 2