Publish the Python exe executable file (using the Py2exe library)

Source: Internet
Author: User

1. Install Py2exe Library, method: Open https://pypi.python.org/pypi/py2exe/0.9.2.0#installation, find Py2exe-0.9.2.0.win32.exe Download the installation (installed by default in the Python source directory) and install it.

2. Create a new folder under the Python source directory (such as C:\Python34) and rename it (such as a Web folder). Put the PY source file (such as web.py) that you want to convert to exe into a folder.

3. Create a new. py source file (named tweb.py) into the Web folder, andthe code in tweb.py is:

From Distutils.core Import Setup
Import Py2exe
Setup (windows=["web.py"])

4. Open cmd and switch the current path to the C:\Python34\web directory.

5. Enter command python tweb.py py2exe, enter, cmd to execute automatically.

6. After execution, find the Dist folder inside the Web folder , there is a Web.exe file. Done.

7. Note that you must copy the entire dist to use Web.exe on other computers.

Attach the web.py code:

Import WebBrowser
Import time
Webbrowser.open ("http://www.baidu.com")
Time.sleep (5)
Webbrowser.open ("http://www.163.com")

Publish the Python exe executable file (using the Py2exe library)

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.