Python Support Tools [1], executable file generation tool, Cx_freeze

Source: Internet
Author: User

Cx_freeze

Cx_freeze is a third-party library that can be used to package Python code into an executable file, and here's how to use a script file to turn Python code into an EXE executable file.

First, you need to install the Cx_freeze, you can use the PIP to install, the installation method is as follows

Pip Install Cx_freeze  

After the installation is complete, create a setup.py file in the same directory as the code that needs to be packaged, enter the following code, where Build_exe_options is a dictionary of optional parameters, packages to the library to be included, excludes to the library that does not need to be included, Include_ Files is the file or folder that you want to include.

ImportSYS fromCx_freezeImportSetup, Executablebuild_exe_options= {"Packages": ["OS","pkg_resources"],                     "excludes": ["Tkinter"],                     "Include_files": ["icons/","scripts/"]}base=NoneifSys.platform = ="Win32": Base="Win32gui"    #base = "Console"Setup (name="Test", Version= 1.0, Description="Python Test", Options= {"Build_exe": Build_exe_options}, Executables= [Executable ("test.py", Base=base)])

Once the configuration is complete, use CMD to open the command-line window and CD to the current directory, and enter the following command to execute the package.

Python setup.py Build  

When finished, a build folder is generated under the directory, which contains the executable file.

Python Support Tools [1], executable file generation tool, Cx_freeze

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.