程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Package Python into exe file

編輯:Python

Preface

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

One 、 install pyinstaller


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

 

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved