Use py2exe to package and release Python programs

Source: Internet
Author: User

Objective: To run a python program on a machine without a python environment installed.

Linux generally comes with python, so it refers to the package release in windows.

Tool: py2exe ,.

Python2.7 is used here. Be sure to download the Python version consistent with that installed on your computer.

If other versions are installed, search by yourself.

Steps:

# How to publish a python program in Windows
#1. Select the program to be released. Assume that its complete path is ppath. Here it is assumed that it is ppath = "D: // nettest. py"
#2. Create a file named setup. py. The file path is random. Assume It is D: \ codes \ Python \ setup. py.

Content:

From distutils. Core import setupimport py2exeppath = "D: // nettest. py" # It is the python Program Setup (console = [ppath]) You want to package.

#3. Enter the win DOS window, that is, the Command Prompt window (note that it is not the python Command Prompt window), switch to the python installation path (the local machine is C: // python27)
#4. Run the following command and enter D: \ codes \ Python \ setup. py py2exe in the Command Prompt window

A large amount of information is generated, indicating that the package is in progress.

#5. generate a new folder Dist under the python installation path, which is the program to be released
#6. You need to publish the entire folder to run it in an environment where python is not installed.
#7. You can directly write a batch to facilitate subsequent release.

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.