A tutorial on using Py2exe to package Python programs into EXE programs under Windows _python

Source: Internet
Author: User

Py2exe downloads in SourceForge only support to 2.7.

For python3.0+ versions, you need to compile them yourself.
1. Download Source

SVN checkout Svn://svn.code.sf.net/p/py2exe/svn/trunk PY2EXE-SVN
2. Compiling environment

The vs2014 is used here.
3. Installation

Enter py2exe-3

Python setup.py Install

This will be compiled and installed.

In addition, Python defaults to the use of VS9, for vs2014, you need to change the file:

Copy Code code as follows:
lib\distutils\msvc9compiler.py

Find:

Copy Code code as follows:
VERSION = Get_build_version ()

Add the following:

Copy Code code as follows:
VERSION = 11.0

If an error occurs:

Copy Code code as follows:
Failed to load and parse the manifest. The system cannot find the file specified.

Error:command ' Mt.exe ' failed with exit status 31

Solution: Because the vs2010 after the link.exe parameters slightly changed, so when link did not generate manifest files, natural Mt.exe can not find this file. Only need to search in msvc9compiler.py inside Manifestfile, then add a line above him ld_args.append ('/manifest '), save on OK. (python3.4 doesn't seem to have this problem, 2.7 exists)
4.setup.py

Setup.py can refer to the official website, where the parameters--bundle-files, need to specifically say, want to play into a whole package to set into 0.

Change can refer to: http://sourceforge.net/p/py2exe/svn/HEAD/tree/trunk/py2exe-3/
last attached setup.py

From Distutils.core Import setup
import py2exe
import Sys,os
 
if sys.version_info.major >= 3.0:
  opt_ Bundle_files = 0
Else:
  opt_bundle_files = 1
includes = ["Pyqt4.qtcore", "Pyqt4.qtgui", "SIP"]
options = {"Py2exe":
     {"Compressed": 1,
      "optimize": 2,
      "includes": Includes,
      "Bundle_files": Opt_bundle_files,
     }
   }
Setup (
  Version = "0.1.0",
  description = "Test_add",
  options = options,
  zipfile=none,
  console=[{"script": "test_add.py", "Icon_resources": [(1, "Py.ico")]},
  #windows =[{"script": "test_add.py", " Icon_resources ": [(1," Py.ico ")]}],
)

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.