Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3 project into exe?

I've made my first Python program, using Python 3.2. Now I'm trying to figure out how to make it an executable.

I pretty much only need it for Windows only. I've searched as much as possible and found out that py2exe doesn't support Python 3. cxfreeze does, but I can't figure out how to make a single executable of my program with it. I need it as a portable one-file exe.

Please bear with me as I am a total newcomer :) Any help is appreciated.

like image 525
Martti Laine Avatar asked Sep 15 '11 05:09

Martti Laine


2 Answers

You can use cxfreeze to make the executable (and other files it creates), compress them into a *.7z archive using 7-zip, then use 7-ZIP SFX Maker to turn it into a self extracting archive.

When creating the SFX archive, configure it so that the main executable cxfreeze generates runs when the files are extracted. You can also change the archives icon, as well as tell the archive to extract and run from a temporary folder.

When the user runs the exe, the files will extract to the temporary folder and the program will run. To the user, it will behave exactly like a normal exe file.

like image 74
pR0Ps Avatar answered Oct 07 '22 20:10

pR0Ps


According to the Python docs, the only program that will package Python3 as an .exe in cx_freeze, and the cx_freeze developer has explicitly stated that he will not support single-file executables (due to the 'dirty hacks' needed, which some anti-malware programs flag as malware).

Comment on the feature request to add Python3 support to py2exe.

like image 20
dotancohen Avatar answered Oct 07 '22 20:10

dotancohen