Py2exe Problems with packaging

Source: Internet
Author: User
Tags glob

Py2exe package python as an. exe file

Packaging process and Results

1. Create a setup script package file, which sets the properties and methods for packaging. Note: Try to place the packaged file in the same directory as this package script (because the non-reproducible search for packaged files fails when you try to use a non-identical directory)

2, on the cmd command line, go to the command line where the setup package script executes, execute this script file (Python setup.py py2exe)

3, the default appears built and dist two files. The contents of the Dist file are the contents of the packager and can be published.

Problems encountered during the packaging process:

1, Win10 System file is missing, the value found these files can be set in the dll_exclude[] property is not included in. There is no file missing when using the Win7 system. Refer to the following documents, which include:

"Api-ms-win-core-string-l1-1-0",

"Api-ms-win-core-libraryloader-l1-2-1.dll",

"Api-ms-win-core-profile-l1-1-0.dll",

"Api-ms-win-core-processthreads-l1-1-2.dll",

"Api-ms-win-core-handle-l1-1-0.dll",

"Api-ms-win-core-registry-l1-1-0.dll",

"Api-ms-win-core-file-l1-2-1.dll",

"Api-ms-win-core-heap-l1-2-0.dll",

"Api-ms-win-core-version-l1-1-1.dll",

"Api-ms-win-core-heap-l2-1-0.dll",

"Api-ms-win-core-io-l1-1-1.dll",

"Api-ms-win-core-localization-l1-2-1.dll",

"Api-ms-win-core-sysinfo-l1-2-1.dll",

"Api-ms-win-core-synch-l1-2-0.dll",

"Api-ms-win-core-errorhandling-l1-1-1.dll",

"Api-ms-win-core-version-l1-1-0.dll",

"Api-ms-win-core-string-l2-1-0.dll",

"Api-ms-win-security-base-l1-2-0.dll",

"Api-ms-win-eventing-provider-l1-1-0.dll",

"Api-ms-win-core-com-l1-1-1.dll",

"Api-ms-win-core-memory-l1-1-2.dll"

2. Memoryloadlibrary failed loading Cv2.pyd This error is decompressed by modifying ZipFile = None so that it generates a packaged file. When you open the program again, the program is packaged successfully and works correctly.

Py2exe Packaging Script property setting problem:

1. Version, Description,name is not required.

2. Windows creates a graphical user interface program

3. Console to create a console program

4, Dist_dir Packaging generated files placed under the dist, you can set the storage directory (generally no special requirements, can not be modified.) Relative paths can be used)

5, compressed default is 0,1 for the specified compressed file (library.zip) behavior; 0 is not compressed.

6, Zipfiles to configure the generated directory and file name of the shared compressed file, by default, a "Library.zip" file is generated under directory dist, packaging the. PYD and. dll files that are required to run the. exe file (not including configuration files, etc.).

7, Optimize Packaging optimization, the legal value is the string ("', ' O ', ' OO ') or integer number (0, 1, or 2). 0 o'clock, without optimization, the size of the package is larger, the package of compiled files for. Pyc;1, a small number of optimizations, the size of the compressed package is slightly smaller, the packaging of the compiled file for. PYO;2, the optimization level is the highest, the compression package size is also significantly smaller, packaged compiled files are. Pyo.

8, Bundle_files Packaging binding, 64-bit does not support this property. 0:pyd and DLL files are not packaged into EXE files; The 1:pyd and DLL files are packaged in an EXE file and cannot be loaded from the file system by the Python module; 2:pyd and DLL files are packaged in EXE files, but Python modules can be loaded from the file system.

Note:. PY: This is the source file that was written.

. PYC: This is a compiled binary code file. If you import a module, Python will create a *.pyc file that is binary in the file, making it easier (faster) to import again.

. PYO: This is a *.PYC file that is generated when optimization level (-O) is turned on.

. PYD: This is equivalent to a Windows DLL file. The. pyd file is actually a DLL file, just slightly different.

9. date_files file The required data for the executable file. In Python27, the required MSVCP90.dll cannot be published separately, you must make sure that Py2exe copies all three DLL files and manifest files to the project directory Dist, and is placed in a subdirectory named ' Microsoft.VC90.CRT '.

Reference procedure for: from glob import Glob data_files = [("Microsoft.VC90.CRT", Glob (R ' C:\Program Files\Microsoft Visual Studio freeze_s Upport9.0\vc\redist\x86\microsoft.vc90.crt\*.* ')]

10, ASCII 0: does not contain the encoding and decoding device; 1 is the reverse.

11, the appearance of Qpixmap::scaled:pixmap is a null pixmap problem, this is because PYQT and QT are the default PNG format of the picture, after packaging, will not find the JPG format of the picture, Therefore, in the packaging process, you need to import the DLL files from the Imageformats folder in the Pyqt4 file. This is a JPG format that requires a plugin for pictures.

12. The class identifier has no attributes, and the resulting CLSID has no attributes.

TypeLibs

List: TypeLibs to be included in the gen_py generated

13, multi-process packaging encountered the program is not normal execution problem, need to call the Freeze_support () function before the multi-process. It is best to call this function first when the function starts executing.

Py2exe Problems with packaging

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.