In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how Python packages exe files. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
First of all, get your code ready, try not to use the Chinese path, it is easy to report errors.
This is the module to be used.
Pyinstaller
It is not the default module of Python, so we need to install it and directly pip install Pyinstaller it.
Partners who will not install the module refer to: how to install the python module, the reasons for the failure of the python module installation and the solution, see how to install it.
After the module is installed, we begin to pack it. Note that all the documents are in English as much as possible so as not to report errors.
First of all, let's change the directory in CMD to the disk where your code is stored, for example, mine is on disk C, type C:, of course, I am already on disk C, so there is no need to switch.
Then copy the file address where your code is located
The fastest thing is to copy it all directly. If you think too much is not good-looking, it depends on where your cmd directory is currently displayed. I'm already here on Administrator, so I can just follow the directory.
Type cd in cmd and then click the space to enter the file directory, so you can successfully switch to the directory you want.
And then the point comes, and now you can start packing, enter the mysterious code pyinstaller-F-w-I aaa.ico zzz.py
A brief introduction to what these codes mean.
1. Pyinstaller (this is the module used to package exe files)
2,-F (this is to generate the exe file, F must be in uppercase, otherwise it will fail, so it must be)
3.-w (lowercase is also fine for this, mainly because after packing, the running file will flash in a black box. It is recommended to add)
4.-I (this is used to replace your icon, replace the file icon with what you want, but with or without)
5. Aaa.ico (this is the icon name + format you are ready to replace, remember to use English, two or three are best, do not use a single letter, some letters will lead to failure)
6. Zzz.py (this is the name of your code file, put at the end)
If you want to replace the icon, first you need to prepare a 32'32 pixel picture file, whether you use a beautiful woman or a handsome guy.
In this format, I would like to introduce you to the easiest way-Baidu jpg online to ico, the first is.
This does not need me to introduce how to operate it, it is very simple, and finally after the conversion is successful, click on the output file name, it will pop up a new window, save as, download it and put it in the same directory with your code.
OK, the foreplay is almost finished. Press enter and start packing.
The exe executable file is in this dist folder
Look, it's perfectly changed to the desired icon.
This is the end of this article on "how to package exe files for Python". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.