Your practical application of packaging Python scripts for py2exeProgramInterested? Do you know how to package Python scripts in py2exe? The two problems are as follows:ArticleI hope you will have a better understanding of it after browsing.
I. Introduction
Py2exe is an executable program (*. in this way, you can run this executable program on windows without installing python. Py2exe has been used to create wxpython, tkinter, PMW, pygtk, pygame, win32com client and server, and other independent programs. Py2exe is released under the open source license.
- application scheme of Python scripts in other language Environments
- advantages of the python scripting language in practical application
- advantages of the vim compiler in Python scripts
- linecount Of The Python script file. py-related code introduction
- Python scripts and C ++ programs call each other
Ii. Install py2exe
Download and run the installer of the py2exe version corresponding to your installed python. This will install py2exe and the corresponding example; these examples are installed in the Lib \ Site-packages \ py2exe \ Samples Directory.
Iii. Usage of py2exe
If you have a file named myscript. you want to convert the Python script of Py to an executable program running on Windows and run it on a Windows system without Python installed, first, you should write a setup script for the release program, such as mysetup. PY, insert the statement import py2exe before the setup function.
An example of mysetup. py is as follows:
- # mysetup. PY
- from distutils. core import setup
- Import py2exe
- Setup ( Console = ["Myscript. py"])
Run mysetup. py as follows:
- Python mysetup. py py2exe
Upload these files.
If your myscript. if the compiled C extension module is used in The py script, these modules will be copied to sub-directories. Similarly, all DLL files are required at runtime, besides system DLL files.
The files in the DIST subdirectory contain what is necessary for your program. You should publish all the content in this subdirectory together.
By default, py2exe creates the following necessary files in the DIST directory:
1. One or more EXE files.
2. Python ##. DLL.
3. Several. PYD files, which are compiled extensions and required by the EXE files. With other. DLL files, these. DLL files are required by. PYD.
4. A library.zip file that contains compiled Python modules such as. PyC or. Pyo
Mysetup.pycreated a console myscript.exe program. If you want to create a program in the graphic user field, you only need to set mysetup. console = ["myscript. replace py "] with Windows = [" myscript. PY. Py2exe can create multiple EXE files at a time. You need to pass the list of these Python script files to the console or Windows keyword parameters.
This is useful if you have several associated scripts. Run the following command to display all command line labels of the py2exe command.
The above is an introduction to how to use py2exe to package the Python script. I hope you will get something.