Package python into executable file under windows system-exe file

Introduction

A few days ago, I wrote an Ocr recognition based on Baidu. An old iron wanted me to show it and asked to show it with exe on windows. I had to quickly add knowledge of
pyinstaller pyinstaller-so that your py can become exe (under Windows Executable file) directly sent to others to run, laymen will not ask any more questions. . .
Below this program OCR text recognition and py Baidu intelligent cloud-based implementation , for example

Install pyinstaller

pip install pyinstaller

use

The following takes packaging setup.py as an example

Package exe

pyinstaller -F setup.py
The -F option is used in the above command. This option specifies that a separate EXE file is generated. Therefore, a separate exe file is generated in the dist directory; the -F option corresponds to the -D option (the default option), this option Specify to generate a directory (containing multiple files) as a program.

Package without console

pyinstaller -F -w setup.py

Package the specified exe icon package

If the default icon is a bit ugly, replace the xxx.ico below with the direct icon name
pyinstaller -F -i -w xx.ico setup.py

Case

The appearance before packaging.
Insert picture description here
Insert picture description here
Insert picture description here
There is no GUI I wrote before packaging. I want to turn it into an executable file exe. Therefore, in the packaging selection, I choose to package without console, that is,
pyinstaller -F -w tkOcrExe.py
enter the directory where the program is located, and enter the code above and press Enter
Insert picture description here
I'll tell the result in a while

24096 INFO: Building EXE from EXE-00.toc completed successfully.

Insert picture description here
You can see that there are 4 more files (folders), and the target exe file is located under the dist folder
Insert picture description here

Version with icon

pyinstaller -F -w -i ocr.ico  tkOcrExe.py

Insert picture description here
Pass the test in the virtual machine
Insert picture description here

References

Guess you like

Origin blog.csdn.net/weixin_43031092/article/details/109162262