about python Why pack it up as exe file , The reason is that it is necessary to configure a certain environment before compiling to transfer source files and source codes to others , And packaged into exe Files can be opened and run like computer software, and can also be shared with others .
PS: This tutorial , We don't have to cmd The little black window of command ;
This tutorial uses :Windows PowerShell(X86)
Remember to use : Administrator run
Pictures are best used ico Suffix picture , Or download a format conversion . Convert and use by yourself
1.1 install pyinstaller, Use the install command :
pip3 install pyinstaller
1.2 If you need to update the version, please enter :
pip install --upgrade pyinstaller
1.3 Check for correct installation
1.4 wait a moment , Water down ;
python There are many packaging tools , Recommended pyinstaller, This tool supports window and linux Next use . stay windows Next , The size is dozens kb The source file , Pack it up exe Files can be tens of megabytes , The reason is that the library files referenced by the program are packaged together .
Two 、python Pack it up exe file ( Packaged with icons )
There are two methods for this packaging , Choose according to your diligence !
2.1 The first one is :cd Package and store in the specified folder
First step : Move to the designated storage exe File folder
cd Folder path
Example : cd Project\Program\PythonWorkspace\MyOpencv\welab
The second step : Just pack it and you're done ( Look at the code )
pyinstaller -F -w -i Path one ( Icon ) Path two (py file )
Example :pyinstaller -F -w -i D:\Opencv.ico D:\Project\Program\PythonWorkspace\MyOpencv\welab\get_location_by_opencv.py
2.2 The second method :cd To py Package and store in the source folder
First step : Move to source file
cd Folder path
Example :cd D:\Project\Program\PythonWorkspace\MyOpencv\welab
The second step : Just pack it up ( Look at the code )
pyinstaller -F -w -i Icon name . suffix Source file .py
Example :pyinstaller -F -w -i D:\Opencv.ico get_location_by_opencv.py
在這部分練習中,We will learn to opera
Packed Linux The executable un