How to compile and convert a Python program into a Windows executable program

Source: Internet
Author: User

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.

 
 
  1. D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>python  
  2. Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) 
    [MSC v.1310 32 bit (Intel)] on  
  3. win32  
  4. Type “help”, “copyright”, “credits” or “license” 
    for more information.  
  5. >>> import compileall  
  6. >>> compileall.compile_dir(“./”, force=1) 

After compilation is complete, run it and check whether it is normal.

 
 
  1. 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.

 
 
  1. rom distutils.core import setup  
  2. import py2exe  
  3. setup(console=['rur_start.py']) 

Then execute

 
 
  1. D:\sunlw\projects\ygclub\teaching\
    rurple1.0rc3>python setup.py py2exe 

Run the exe program.

 
 
  1. 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.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.