Convert executable file under Windows

When developers share software with ordinary users to facilitate the work of ordinary users without installing the Python environment, the development of the developed program is necessary to convert it into a file type that users can run.

Pyinstaller is a tool for compiling scene execution files. The way to install this tool is very simple. It can run on Windows, MacOS X and GNU/Linux operating systems. It supports two versions of Python2 and Python3, and in different operating system environments, the use of Pyinstaller tools is the same.

It should be noted that the executable file packaged by Pyinstaller can only run in the same environment as the types of systems that perform the package operations. In other words, these implementation files do not contain an implant. For example, under the Windows system, the implementation file generated by Pyinstaller can only run in the Windows environment, while the implementation file generated on the Linux system can only run in the Linux environment.

1. Download Pyinstaller from the official website

Visit https://pypi.org/project/pyinstaller to download the Pyinstaller setup package to unzip the downloaded Pyinstaller zip package file

2. Install Pyinstaller

Under the decompressed folder containing the setup.py file, you can install Pyinstaller by running the following command

python setup.py install

3. Prepare the packing file for packaging

Prepare the Python file to be packaged and the type of code required. Note that the icon must be of type .ico. Put two files in a folder, open the path where the folder is located via a CMD window and run the following command for the package process:

pyinstaller -F -i snail.ico 


Hint for successful packaging

4. Beta test

The packaged EXE file is stored in a remote directory

The packaged test.py code content is as shown below

Running a test.exe demo leads to Distil which can work fine and the result is consistent with the actual code. It should be noted that computer anti-virus software may be reported during EXE file replication. Please operate it after trust

Experimental reference book: “Python Security Python Attack Offensive and Defensive Penetration Testing Actual Procedures”

Leave a Comment