Using Py2exe to convert a python program to an EXE file under Windows

Source: Internet
Author: User
Prerequisites:
The Easy-install module needs to be installed, which is a Python module packaging tool.

First download the easy_setup.py source code, download the address:
Http://pypi.python.org/pypi/setuptools
Use Notepad to store the source code with the. py suffix name, execute at the command line, so you can see in the Python installation directory python\scripts This directory there are several files about Easy_install, indicating that this easy_install installed , how should you use this installation method?

Open cmd, command line, into the python\scripts directory, under this directory execute Easy_install python-dateutil, can install dateutil this module, Easy_install Pyparsing can install pyparsing this module.

My machine is:

The execution is OK!

Py2exe Module Installation:
Http://prdownloads.sourceforge.net/py2exe download the corresponding version of the installation package.

Sample code:
Create a new test.py file with the following contents:

Create a new mysetup.py compilation file with the following content:

Run the following command:

>>python mysetup.py Py2exe

Operation Result:
A new dist directory in the current directory contains the following types of files with unequal numbers:

    • . exe contains a catalog file
    • . PYD compiled py file
    • The. dll requires an external DLL file containing a Pythonxx.dll
    • . zip needs to use the library file, which packed all the library files need to compile files

View Help:

Sample catalog:
After installing the Py2exe module, its own sample is stored in: lib\site-packages\py2exe\samples

Description
The parameters required to compile different types of binaries are not the same, for example: the command-line program parameter name is the console, and the GUI program's parameter name is Windows, you can refer to the sample or HELP command script first!

Use after feeling:
Originally thought to be converted after the only one EXE file, used to find and did not want to imagine that all the content has been encoded in binary. Hehe, sometimes think of things too ideal, after all, this is the easiest way to achieve the feasible solution!

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