开发者

Python 3 project into exe?

开发者 https://www.devze.com 2023-04-04 19:21 出处:网络
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'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.


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.


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.


You can compare py2exe folder structure with new python3, and make similar. Then you could use SFX idea to store these folders like libraries, python script and interpreter and set script for SFX to just launch your application. As I remember, this is possible in WinRar, and as I think now, in other archivers.

0

精彩评论

暂无评论...
验证码 换一张
取 消