1. Install Pyinstaller
When using Python to package EXE executable files, you need to use Pyinstaller and use the command pip install PyInstaller to install it, as follows Picture:
After installing Pyinstaller, you can use it to package .py files. There are two situations for packaging, one is to package the console program, and the other is to package the console program. The first is to package and use a GUI program designed similar to PyQt
2. Package the console program
Open the cmd command window and use the cd command to switch to the path where the .py file is located. Then use the pyinstaller -F Test.py command to package, as shown below:
3. Pack the GUI program
Open the cmd command window, use the cd command to switch to the path where the .py file is located, and then use pyinstaller --paths C:Users......Python37/Lib/site-packages/PyQt5/Qt/bin -F -w --icon=note .ico main.py command for packaging, as shown below:
# Among them, --paths is used to set the environment variables of PyQt, and -F means to generate a single exe executable file. -w represents a form program, --icon is to set the display icon of the exe, main.py is the entrance to the GUI program
Note: When packaging a GUI program, if resource files such as pictures are used in the program, the packaging is completed Finally, you need to copy the resource files (folders) used to the dist folder.
Recommended tutorial: python tutorial
The above is the detailed content of python package exe executable file. For more information, please follow other related articles on the PHP Chinese website!