Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run python program via clickable desktop icon [duplicate]

I've made a python program using Tkinter(GUI) and I would like to enter it by creating a dedicated icon on my desktop. (I want to send the file to my friend, without him having to install python or any interpreter)

the file is a some-what game that I want to share with friends and family, which are not familiar with coding.

like image 550
Hadar Avatar asked Sep 16 '25 09:09

Hadar


2 Answers

You can simply use Pyinstaller to create a standalone .exe.

Run this from the Windows cmd to create a standalone executable file: pyinstaller.exe --onefile --noconsole --icon=your_image_here.ico app.py

like image 147
ErikDM Avatar answered Sep 17 '25 22:09

ErikDM


you can install Pyinstaller by using pip

pip install pyinstaller

go to the directory where your file is saved and type:

pyinstaller.exe --onefile --windowed path/to/your/file.py

--onefile (compresses your files into one .exe file) --windowed (removes the console when you run your file) path/to/your/file.py (or simply file.py when you want to convert the file in the same directory)

if you have any error using it, remove the --windowed flag and run file.exe on command line to see the error

like image 45
Virtual Dreamer Avatar answered Sep 17 '25 21:09

Virtual Dreamer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!