In general, two approaches are often recommended:
1.PyInstaller Packaging Generation EXE
2. How to use Py2exe package to generate EXE
-----------------------------------------------------------
Package Download Place:
http://www.python.org/to the official website, and then into the PyPI "python package Index" Python all the packages are basically available here
1.PyInstaller Packaging Generation EXE
Tool decompression is available.
Instructions and procedures for use:
1. Install Python
2. Install the corresponding version of the pywin32-219.win32-py2.7
3. Download the PyInstaller-2.1 version and unzip it into the Python directory "recommended to do so, actually unzip the directory arbitrarily"
4. Go to the directory where the pyinstaller.py is located, go to run
For example: "c:\python27\pythontoexe\pyinstaller2.1>pyinstaller.py htsource\1.py"
Explanation: I put the software in the C:\Python27\pythontoexe\PyInstaller2.1 directory.
My Python code is on "C:\Python27\pythontoexe\PyInstaller2.1\1.py"
5. Finally generate 1 "same name as source code" folder under "C:\Python27\pythontoexe\PyInstaller2.1" directory
The program under the Dist directory under this file is the program to be generated.
6. Generate a lot of files in the Pyinstaller2.1\1\dist directory, you need to save all the files
Note: For component download, you need to enter PyPI on the Python website to search for the appropriate library.
------------------------------------------------------------------------------
How to generate a single file:
Generate a Httest.exe file in the Pyinstaller2.1\1\dist directory for easy publication and easy access to customers
>pyinstaller.py-f htsource\httest.py #只是比原来多个了 "-F" parameters
Just generate a Httest.exe file
------------------------------------------------------------------------------
ICO change icon problem, follow up next,-I parameter
Instance:
To generate a program with an icon:
C:\python27\pythontoexe\pyinstaller2.1>pyinstaller.py-f--icon=test.ico htsource\httest.py
Parameter description:-F generates a single file
--icon=test.ico selection icon for the build program
htsource\httest.py Source program code
Note: The Test.ico icon is stored in the PyInstaller2.1 directory, so that you can implement the icon of the generated program to choose freely
------------------------------------------------------------------------------------------------------------
2.py2exe
1 Relative Perfect program #可以生成 a program with icons
From Distutils.core import setup
Import py2exe
Import sys
includes = ["Encodings", "Enco dings.* "]
Sys.argv.append (" Py2exe ")
options = {" Py2exe ": {" Bundle_files ": 1}
}
Setup (options = options,
zipfile=none,
console = [{"Script": ' httest.py ', ' Icon_ Resources ': [(1, ' Test.ico ')]}])
--------------------------------------- ---------------------------------------------------------------------------------
2. Generate a file
From Distutils.core Import Setup
Import Py2exe
Import Sys
includes = ["Encodings", "encodings.*"]
Sys.argv.append ("Py2exe")
Options = {"Py2exe": {"Bundle_files": 1}
}
Setup (options = options,
Zipfile=none,
console = [{"Script":' httest.py'}])
--------------------------------------------------------------------------------
3.GUI interface of the program
From Distutils.core Import Setup
Import Py2exe
Setup(Windows=["123.py"])
--------------------------------------------------------------------------------------------------------------- ---------
4. Script file generation
From Distutils.core Import Setup
Import Py2exe
Setup (console=["httest.py"])
--------------------------------------------------------------------------------------------------------------- ---------
Python compiled into EXE file