Py2exe packaging problems, py2exe packaging problems
Py2exepackage pythoninto the. exe file
Packaging process and result
1. Create a setup script package file and set the packaging properties and methods. Note: Try to put the package file and the package script in the same directory (because an error occurred while trying to find the package file that is not reproducible)
2. On the cmd command line, go to the command line where the setup package script is located and run the script file (python setup. py py2exe)
3. the built and dist files are displayed by default. The content in the dist file is the package content, which can also be published.
Problems encountered during packaging:
1. Windows 10 system files are missing. If the values are returned, these files can be excluded from the dll_exclude [] attribute. When Windows 7 is used, no file is missing. Refer to the following files, including:
"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. Modify zipfile = None to generate the package file and decompress it. When you open the program again, the program is packaged successfully and runs properly.
Py2exe packaging Script Attribute settings:
1. Version, Description, and Name are not required.
2. Create a graphical user interface program in Windows
3. Create a Console program on the Console
4. Put the files generated by the dist_dir package in dist and set the storage directory. (generally, there are no special requirements and you do not need to modify the directory. Available relative paths)
5. When Compressed is, it indicates the action of the Compressed file (library.zip), and 0 indicates that the file is not Compressed.
6. Zipfiles is used to configure the Directory and file name for generating shared compressed files. By default, a “library.zip file is generated under the directory dist and packaged.. pyd and. dll files (excluding configuration files ).
7. Optimize packaging optimization. Valid values include string (', 'O', 'oo') and INTEGER (0, 1, or 2 ). When the value is 0, No optimization is performed. The size of the compressed package is large and the package compilation file is. pyc; 1, a small number of optimizations, the size of the compressed package is slightly smaller, the packaging of the compilation file is. pyo; 2, the optimization level is the highest, the size of the compressed package is also significantly smaller, the package compilation file is. pyo.
8. Bundle_files is packed and bound. This attribute is not supported by 64-bit. 0: pyd and dll files will not be packaged into the exe file; 1: pyd and dll files will be packaged into the exe file, and the python module cannot be loaded from the file system; 2: the pyd and dll files are packaged into the exe file, but the python module can be loaded from the file system.
Note:. py: This is the written source file.
. Pyc: This is a compiled binary code file. if a module is imported, python creates *. the pyc file contains binary code, which makes it easier (faster) to import data again ).
. Pyo: This is a *. pyc file generated when the optimization level (-O) is enabled.
. Pyd: This is equivalent to a windows dll file. In fact, the. pyd file is a dll file, but it is slightly different.
9. data required for the executable file of the Date_files file. In python27, the required MSVCP90.dll cannot be released separately. You must ensure that py2exe copies all three dll files and manifest files to the project directory dist and put them in a project named 'Microsoft. in the subdirectory of VC90.CRT.
Reference Method: from glob import glob data_files = [("Microsoft. VC90.CRT ", glob (r 'C: \ Program Files \ Microsoft Visual Studio freeze_support9.0 \ VC \ redist \ x86 \ Microsoft. VC90.CRT \*. * ')]
10. ascii 0: the encoding and decoder are not included; 1 is the opposite.
11. QPixmap: scaled: Pixmap is a null pixmap problem. This is because both pyqt and qt use the default png format. After packaging, they cannot find jpg images, therefore, you need to import the dll file in the imageformats folder of the pyqt4 file during the packaging process. This is a plug-in for jpg images.
12. The Class Identifier has no attribute, and the generated CLSID has no attribute.
Typelibs |
List: typelibs generated by gen_py to be included |
13. If you encounter abnormal program execution during multi-process packaging, you need to call the freeze_support () function before multi-process packaging. After testing, it is best to call this function first when the function starts to be executed.