pyinstaller packages py files into EXE files (nanny-level tutorial)

1. Installation of the PyInstaller library

1. General installation steps:

The general installation method of pip install pyinstaller is to enter in the cmd command prompt environment:

window+r run cmd

Enter the following to switch to the pip directory

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_20,color_FFFFFF,t_70,g_se,x_16

Type pip install pyinstaller

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_20,color_FFFFFF,t_70,g_se,x_16

 2. Install PyInstaller using python

open python settings

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_13,color_FFFFFF,t_70,g_se,x_16

item added

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_20,color_FFFFFF,t_70,g_se,x_16

 Search for installation packageswatermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_20,color_FFFFFF,t_70,g_se,x_16

 The installation is complete

 

Second, the use of pyinstaller

Open the cmd command prompt and switch to the pyinstaller directory

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_20,color_FFFFFF,t_70,g_se,x_16

 Enter pyinstaller.py -F filename.py (the file needs to be in the pyinstaller directory)

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbG92ZTk1OTk=,size_20,color_FFFFFF,t_70,g_se,x_16

This file is packaged into an exe file

2.1, PyInstaller command line options

parameter illustrate
-F Generate a single executable
-D produces a directory (containing multiple files) as an executable program
-a Does not include Unicode character set support
-in -w Specifies that the program runs without displaying the command line window (only valid for Windows)
-c Specifies to use the command line window to run the program (only valid for Windows
-O Specifies the build directory for spec files. If not specified, the current directory is used by default to generate the spec file
-p Sets the path to Python imported modules (similar to setting the PYTHONPATH environment variable). You can also use a path separator (semicolon on Windows, colon on Linux) to separate multiple paths
-n  Specifies the project (generated spec) name. If this option is omitted, the name of the main file of the first script will be used as the name of the spec
-i Specifies the icon for executables on Windows/Mac platforms.

The above is the whole content of this time. There are actually more advanced operations about pyinstaller packaging. You can read more about the official documentation, mainly the command line parameters and the configuration points in the spec file .

 

 

 

Guess you like

Origin blog.csdn.net/weixin_67281781/article/details/123694294