Home >Backend Development >Python Tutorial >python package exe executable file

python package exe executable file

王林
王林Original
2020-05-11 13:47:445823browse

python package exe executable file

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:

python package exe executable file

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:

python package exe executable file

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:

python package exe executable file

# 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn