Python program compilation can be used to convert certain executable programs in actual applications. The following article describes how to compile and convert a Python program into a Windows executable program, the following is a detailed description of the article. I hope you will gain some benefits.
Install the following package before compiling and packaging:
Python2.5
WxPython 2.6.
Py2exe 0.6.5-the first version that supports Python2.5
Compile the program into the directory of the python file to be compiled as follows.
- D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>python
- Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54)
[MSC v.1310 32 bit (Intel)] on
- win32
- Type “help”, “copyright”, “credits” or “license”
for more information.
- >>> import compileall
- >>> compileall.compile_dir(“./”, force=1)
After compilation is complete, run it and check whether it is normal.
- D:\sunlw\projects\ygclub\teaching\rurple1.
0rc3>rur_start.py
It seems to be a little faster. Package the program into exe and add the setup. py file. The code below f is an indispensable part of the code for compiling and converting the Python program into a Windows executable program.
- rom distutils.core import setup
- import py2exe
- setup(console=['rur_start.py'])
Then execute
- D:\sunlw\projects\ygclub\teaching\
rurple1.0rc3>python setup.py py2exe
Run the exe program.
- D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>.
\dist\rur_start.exe
Successful.
The content of the above article is an introduction to the actual operation steps for compiling and converting a Python program into a Windows executable program.