Recently, due to project needs, previous Python files need to be edited as EXE for front-end customers to use.
Since the earliest contact is distutils, it is ready to use Distutils and Py2exe collocation for the Python exe, that is, the traditional use of setup.py way to do EXE installation. But the results are not very good, not very satisfactory. And a python package used by Py2exe is mutually exclusive, so long as the package is installed, it cannot be EXE-formatted. Even if the code does not need to import, it will error.
Therefore, can only reluctantly abandon the Py2exe tool. Use Pyinstaller instead. The use of feelings really is dumped py2exe a few streets. The first is the installation,
Pip Install Pyinstaller
Note: The latest version of Pyinstaller is 3.2.1 only supports 2.7-3.5. However, the latest development version is supported for python3.6 in the develop branch of the link below. Since I am using the 3.6 version. So it's been looking for a long time.
Https://github.com/pyinstaller/pyinstaller
Pyinstaller after installation, only the name of the Pyinstaller installation package will be used:
Pyinstaller hello.py
You can package the hello file. The package file is in the Pyinstaller directory. You can modify the saved location by using the--distpath=xxxx parameter.
There are some other parameters this article also directly found the information on the Internet, as follows:
Introduction to Publishing commands
- 1
There are two ways to invoke the publishing process:
① calling a script to be published directly using the Pyinstaller application
② calling the Pyinstaller-script script in Python and then calling the script to be published
There is no difference between the two methods, the method ① a few steps, the method ①.
- 2
-w directive
Directly published EXE app with command-line Debug window, add-w command inside directive can block
- 3
-F directive
Note the directives are case-sensitive. This is uppercase. Use the-F directive to package your app as a standalone EXE file, or a folder with various DLLs and dependent files
- 4
-P directive
You can add the path to the Pyinstaller search module later in this instruction. Because there are many modules involved in app packaging. Here you can add the path yourself. But after the author tests, the Site-packages directory can be recognized, do not need to manually add
Original URL:
Https://jingyan.baidu.com/article/a378c960b47034b3282830bb.html
Python Packaging exe artifact Pyinstaller