Python Forum
How to shorten the size of program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to shorten the size of program
#11
Thanks for support. could you send the output you get? namly what you did.
Reply
#12
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python multiple try except block in my code -- can we shorten code mg24 10 5,894 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  Want to shorten the python code shantanu97 3 1,234 Apr-25-2022, 01:12 PM
Last Post: snippsat
  size of set vs size of dict zweb 0 2,119 Oct-11-2019, 01:32 AM
Last Post: zweb
  CSV file created is huge in size. How to reduce the size? pramoddsrb 0 10,435 Apr-26-2018, 12:38 AM
Last Post: pramoddsrb
  how to add smilar size python interpreter to my program. harun2525 7 5,614 Feb-25-2017, 09:14 PM
Last Post: snippsat
  How do I shorten my input options? - text adventure ShiningKnight 3 4,624 Jan-01-2017, 03:21 AM
Last Post: ichabod801
  Shorten this List Comprehension ATXpython 7 6,919 Oct-10-2016, 07:50 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020