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.
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
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.
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.
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/
6. Put the converted picture in the project folder and enter the following command:
pyinstaller -F -i lover.ico love.py
7. That's it, and an executable project with icons is generated. The effect is as follows: Remember to like it! ! !