How to convert a Python program to an EXE file

Source: Internet
Author: User

In the Python programming language, developed programs can be converted into EXE files for specific operations. Here, we will give you a detailed introduction to the operations on converting a Python program into an EXE file, so that you can get some help.

  • Analysis of basic Python String applications
  • Summary of Python Process Control keywords
  • Introduction to two common methods for connecting Python to a database
  • Tips for sharing Python Chinese Characters
  • Summary of common Python application scopes

The most common method for converting a Python program to an EXE file is py2exe, but it is on windows.

On the linux platform, you can use the freeze module that comes with python. Its usage is as follows:

Python

 
 
  1. < path of your freeze.py> [options] < entry file of your python program> 

To find freeze. py, you can use "locate freeze"

For example:

I have five py files, under the gen directory (main. py, print. py, depot. py, gen. py, config. py), and main. py is the entry of the program.

I can convert the Python program to an EXE file in this way:

 
 
  1. python < path of your freeze.py> -o dist main.py 

In this way, all generated files are put under the dist directory, and then

 
 
  1. cd dist  
  2. make 

Now we can see the exe file (gen. Generally there are more than 4 m.

You can use the strip command to slim down the exe file.
 

 
 
  1. strip gen 

It may be less than 3 MB. The above describes how to convert a Python program into an EXE file.

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.