In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article "python how to hide the console at run time" is not understood by most people, so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "python how to hide the console at run time" article.
Install virtual environment install pyinstallerpip install pyinstaller package exe command: (there are a lot of specific commands online) # package a py file and hide the execution window pyinstaller-F-w main.py # package a py file (- F) and hide the execution window (- w), replace the exe ico icon (- I img.ico) pyinstaller-F-w-I img.ico main.py
The above packaging will save various dependent libraries to a folder as a source file, and most of the time we still want to have only one exe file.
Package all dependent libraries in the folder into exe: # merge into one exe (--onefile), replace exe icon (--icon=img.ico), py source file (main.py), hide execution (- w) pyinstaller-- onefile-- icon=img.ico main.py-w
Note:
When all dependent libraries are packaged into an exe and executed in a hidden CMD window, an error occurs, resulting in the program not running properly, so you need to use
Subprocess to execute the CMD command. Executing the cmd command in this way will not cause a program error. Import subprocess cmd = 'your CMD command' res = subprocess.call (cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) simply hide the console
Change the suffix .py to .pyw
After the modification, you can see Python File (no console) (.pyw) in the file attributes.
When no console is displayed, the command window will not pop up at run time.
The above is about the content of this article on "how to hide the console when python is running". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
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.