In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to package Python code into .exe executable files". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Download pyinstaller
PyInstaller is a very useful third-party library, which can package Python source files under Windows, Linux, Mac OS X and other operating systems. By packaging the source files, Python programs can be run in an environment where Python is not installed, or it can be easily transferred and managed as an independent file.
Because there are many tripartite packages in Python, if we want these tripartite packages to be included, we need a tool, pyinstaller, which is very simple, type pip install pyinstaller directly on the command line.
Or use an image to download
Pip install pyinstaller-i https://mirrors.aliyun.com/pypi/simple
two。 Put the code you need to package into the pyinstaller folder you just downloaded
2.1 find the path configured in your environment variable, for example, my path is "C:JohnsonIDEAnacondaanaconda3envs f2"
2.2 then put the code you need to package into the Libsite-packagesPyInstaller (the pyinstaller you just downloaded) folder under the environment variable.
For example, I want to implement an automatic screenshot code, name it 1.py, and put it under pyinstaller.
Note: this step can also be configured according to your own virtual environment
2.3 find a suitable ico icon, you can also find pictures in jpeg or other formats, and then Baidu search online jpeg to ico icon to convert your images into ico icons.
Note: you don't have to do this step, which is the default icon
2.4 enter pyinstaller-I x.ico-F-c y.py at the cmd command line under the corresponding directory of pyinstaller
Where:
-I: indicates the icon to be loaded (you don't have to write without selecting the icon)
X.ico: indicates the icon name of your choice (you don't have to write if you don't select an icon)
-F: indicates that it is packaged into an .exe executable
-c: indicates that the packager has a window
Y.py: indicates the py file you want to package
After executing the program, you will find that there is a self-generated .exe file in the dist directory under the pyinstaller directory.
Then double-click to run the 1.exe file and find that it can be executed and sent to other computers that do not have Python.
This is the end of "how to package Python code into an .exe executable file". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.