This document describes how to use cx_freeze and pyinstaller to package python scripts as exe files.
Wxapp. py, read_file.py, setup. py
(self, parent=None, title=== wx.Button(panel, -1, = wx.Button(panel, -1, ==wx.ALL, border=20=wx.ALL, border=20==wx.ALL |= getattr(sys, == os.path.dirname(= os.path.join(path, , == App(1
= line
cx_Freeze = {: 2: [= sys.platform == = = [Executable(script========= {=executables)
Open cmd to enter the code directory, and enter:
a = Analysis([=[======os.path.join(, ======, r, =)
Open cmd, switch to the pyinstaller directory, and enter the following command:
Python pyinstaller. py path_of_spec (PS: replace path_of_spec with the absolute path of your stored wxapp. spec. You can drag it to cmd to get the path.
I used upx for compression here, or you can skip it. For details, refer to the official website.
After the execution is complete, the wxapp folder is generated. wxapp/dist/distridemo.exe and read_file.py are the files you need.
Now, the two packaging methods cx_freeze and pyinstaller have been introduced. I personally prefer pyinstaller, strong customization, automatic search module dependency, the ability to generate separate exe files, detailed official documentation, disadvantages do not support py3.x, but now most of the world is py2.x...
I believe that pyinstaller will follow up shortly when py3.x becomes popular.
January 23, 2014 20:03:36 update
For pyinstaller usage updates, I read the instructions on the official website again today. For the spec file, I can use a tool to automatically generate one. The command is as follows:
pyi-makespec webapp.py file_read.py
This will generate a wxapp. the spec file can be modified on the basis of this file. Here I only mention a few things to note. In the EXE option, exclude_binaries controls whether to package it into a separate exe file, note that if your software needs to read and write a configuration file, and the configuration file is in the same directory as the app, in your py file, you need to reference the path of this configuration file as follows: BASEDIR = OS. path. dirname (_ file _) to obtain the configuration file, and then use CONFIG_PATH = OS. path. join (BASEDIR, 'config. ini ') to specify the path of the configuration file. nothing else to pay attention
After modifying the spec file, you can use the following command to generate the exe file:
pyi-build wxapp.spec --upx-dir=dir_path_of_upx
By: msccreater
Reprinted please indicate the source: http://www.cnblogs.com/msccreater/p/3530250.html