Return Home

Captains Log 0004

May 1, 2025

Executable Scripts

What I've learned using PyInstaller to bundle my programs. The purpose is to allow people who do not have python installed to be able to run my programs.

First test: installed pyinstaller. Open up my terminal session and run the command "pyinstaller --noconsole --onefile --icon worm.ico --name worm wormfriend.py"
This seemed like it worked, --noconsole [doesnt open a terminal sesh when program is ran] --onefile [bundles everything up into a single .exe], --icon [sets icon to my file "worm.ico"], --name [name of program] and then "wormfriend.py which is the name of my script.

Testing it on my computer it works fine, but I have python so I sent it to my work PC which doesn't and discovered I got an error that it cannot open worm.ico, no such file exists. So my art files didn't make it into the bundling process. Trying something new

edit code to call the "relative path" for file locations you need to add to the onefile, then include them when building it with pyinstaller like I did below. See if this works.

runing the command" pyinstaller --noconsole --onefile --add-data="artfile.gif;." --icon="worm.ico;." worm.py
as well as deleting the old files from the Build and Dist folders created by pyinstaller

seems like this does the trick :). Very very cool

Return Home