Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

python - How would I combine multiple .py files into one .exe with Py2Exe

I used PyQt to make a GUI for my program, but it has multiple .py files, 2 are them are classes, and one launches the code. So I was wondering, how would I combine them into one whole program?

Here is a download link to all the .py files I will be combining: http://www.multiupload.com/CJDL639CTH

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Shed Skin can turn your program into a fast executable, but maybe that doesn't work for your program.

With py2exe and a setup.py like this you can easily turn your Python 2.x code in Windows into an executable with only one extra file, unlike cx_Freeze's flat output of 11 files. For Python 3, use cx_Freeze, or py2exe.

The key part is:

    options={
            'py2exe': {
                    'compressed': 2,
                    'optimize': 2,
                    'includes': includes,
                    'excludes': excludes,
                    'packages': packages,
                    'dll_excludes': dll_excludes,
                    'bundle_files': 1,  # 1 = .exe; 2 = .zip; 3 = separate
                    'dist_dir': 'dist',  # Put .exe in dist/
                    'xref': False,
                    'skip_archive': False,
                    'ascii': False,
                    'custom_boot_script': '',
                    #'unbuffered': True,  # Immediately flush output.
            }
    },
    zipfile=None,  # Put libs into .exe to save space.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...