Preface
In order for others to call the python script we wrote more conveniently without installing the python environment, this blog post will briefly introduce how to package the python script into an exe.
pyinstaller
Many programming language IDEs come with packaging functions by default, and Python packaging is relatively "out of nowhere", and requires additional installation of a third-party packaging tool library. I used the pyinstaller library here.
Enter the following command to install:
pip install PyInstaller
Installation method one
In the main program directory, enter the cmd window and enter the following command:
pyinstaller -F genSample.py
Installation method two
In order to personalize the exe icon, in the cmd window, enter the following command:
pyinstaller -F -i Batman.ico genSample.py
The icon I used is shown below:
PS: The icon path should be in the main program directory
The generated exe looks like this: