Python code directly generates executable exe file

Foreword:

There is a very powerful library in python that can directly package the written python code into an executable .exe file. The generated file can be directly run by double-clicking without the python operating environment and IDE such as pycharm. Isn't it great! In this way, you can develop some simple mini games and send them directly to your friends to play. Your friends will definitely look at you with admiration. You can also write a confession code and send it to your girlfriend. Your girlfriend will definitely think you are great, and it will be a matter of course! Haha.

 
 
Insert picture description here
 
 

1. First install the pyinstaller library:

 

pip install pyinstaller

 

2.: Enter the following command under the created project: love.py is the name of the project

 

pyinstaller -F love.py

 
Insert picture description here
 
 

3. At this time, you will find that 3 files will be generated: build, dist and love.spec, there will be love.exe executable file in the dist folder, so it is packaged.

 
 
Insert picture description here
 
 

4. The project file generated by the above method does not specify an icon, and the default icon is not very beautiful. We can DIY a beautiful icon that we like. We search for "Ali Vector" on Baidu, and we can find many icons that we like.

 
 
Insert picture description here
 
 

5. The downloaded picture is in png format. We need to convert the format and convert it to ico format. Search for an online format conversion tool on the Internet: the link is as follows, and the size is 16*16.

https://www.easyicon.net/covert/

 
Insert picture description here
 
 

6. Put the converted picture in the project folder and enter the following command:

 

pyinstaller -F -i lover.ico love.py

 
 
Insert picture description here
 
 

7. That's it, and an executable project with icons is generated. The effect is as follows: Remember to like it! ! !

 
 

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43697214/article/details/103015771