Problem
The problem is that pyinstaller
automatically bundles everything into your myprogram
folder under dist
. In that folder, you will find a myprogram.exe
file that you can run. However, this isn't that convenient.
Solution
Adding the option, --onefile
, such that pyinstaller --onefile myprogram.py
should bundle all files into one exe
under the dist
folder.
-F
will also work; however, it's less readable if you're going to come back to it later.
Footnotes
This will create a console when you run the .exe
file - if you have a GUI in your script (like Tkinter or PyQt), use --windowed
.
Alternatively, you could do --onedir
and send your friend an entire folder - may be a little easier.
Adding the --add-data {filename}:DATA
will bundle files with your exe - use sys._MEIPASS
(see this great StackOverflow post).
And finally, if you're just printing stuff, the console window will close as soon as everything's done.
See here for other options commonly used.