Use the latest pitfall practice record of Pyinstaller, pyinstaller

Source: Internet
Author: User

Use the latest pitfall practice record of Pyinstaller, pyinstaller

Preface

The Pyinstaller can be translated into an executable file using pyinstaller. This document describes how to use pyinstallerto convert pythonprogram .pyto .exe. Before starting this article, we recommend that you read this article. This article describes Pyinstaller's latest practices, currently, the pyinstaller questions on the Internet are filled with various answers from the past. This is probably the most annoying part of various brainless blog crawlers.
In addition, stackoverflow is a strange answer to this question.

Strongly recommended official document http://pythonhosted.org/PyInstaller/usage.html#options

Introduction

Here we will record my two solutions. The first one was actually written on the Internet, but it was too easy to be overwhelmed by various noises. The second is to find a solution for one afternoon.

1. Missing PYTHON2X. DLL

Declare the environment first

Windows10 + python2.7.11 64bit + pyqt4 64bit + pyinstaller3.2 Solution

There are several types of errors on the Internet:

  • I manually searched for the. dll file and moved it to the corresponding folder. This is the most widely used method on the Internet. It is invalid after testing.
  • Modifying the SPEC file and adding various paths makes it a headache to manually add paths.
  • You also need to manually add the path when using the-path parameter during compilation.

In fact, the official document provides a parameter

--win-private-assemblies

This parameter changes the shared assembly to a private assembly. In this way, even if the environment is changed, the compiled program will only execute the private assembly and ignore the shared assembly in different environments. This parameter is especially suitable for execution in different environments after compilation on a machine.

There is also a parameter similar

--win-no-prefer-redirects

These two parameters are only available in the new pyinstaller version, so the old blog of The crawler site copy will not introduce this method.

2. Windows 32BIT prompts that the program is invalid

The environment is as follows:

Windows2k3 32bit + python 2.7.11 32bit + pyqt 32bit + pyinstaller2.1 Solution

In fact, there is a need to execute the packaged pyqt on the 32-bit win2003.

Initially, a 32-bit python + pyqt + pyinstaller with the latest version was installed and compiled and executed successfully on the 32-bit win7, however, if you put a 32-bit program on 2003, the error message is that the win32 program is invalid. At first, I suspected that the 32-bit version of 2003 is different from that of win7?

As a result, the same error was reported after the compilation of the latest program on win2003.

After the search fails, I accidentally saw a Post saying that PHP5.5 does not support Win2003. At runtime, the error win32 program is invalid, I suddenly thought that it would be the component used for compilation that also does not support Win2003?

Unpackaged programs can be executed on 2003, which is mostly a pyinstaller problem. You can directly roll back the pyinstaller to the latest version 2.1 in the official list, only Python 2.1 and earlier versions are supported. If the package is successful, no error is returned.

However, there is another small problem here. The packaged pyqt program does not have any effect after clicking it. This suspicion is a parameter problem. After testing, we found that, first of all, the old version of pyinstaller does not have the commands I mentioned earlier to change the Assembly. Second, if the command line box is removed using-w, pyqt cannot be executed, therefore, only the-F-clean parameters are used for packaging. After testing, the file can be executed.

Others

In fact, there are still some small questions, but the answers to these questions are easy to find. I will not go into detail here.

  • The pywin32 official website is very easy to go to the corresponding version
  • The official pyqt installation package is no longer available. You can go to sourceforge to download
  • The VC error is reported during compilation. Install Microsoft Visual C ++ 20xx Redistributable Package. Pay attention to 32-bit and 64-bit

Summary

The above is all the content of this article. I hope the content of this article has some reference and learning value for everyone's learning or work. If you have any questions, please leave a message to us, thank you for your support.

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.