简体   繁体   中英

Py2exe executable shows black command line window

There was a simple task - well, in Python it took around one hundred lines of code (the task was only to ask users for input files, process them and write results on disk). But the requirement was that it must be executable on PCs without Python interpreter. I used py2exe to make an executable file (it has increased the size from 3Kb to ~12 Mb but doesn't really matter).

The problem is - when one tries to run this *.exe, it shows black command line window for half a minute and only after that - file-selecting dialogue. Is there a possibility to get rid of that half-minute delay? Of maybe there are other .py to .exe converters which would suit better in this situation?

In py2exe

console = ['yourscript.py']

will generate a command window, use the following instead

windows = ['yourscript.py']

http://www.py2exe.org/index.cgi/ListOfOptions

This is perfectly normal when making exe files with Python code. When you make an executable file, Python itself is bundled into the .exe. This is so the user does not have to install Python on their machine to make it work. Python is an interpreted language and requires the interpreter to be bundled.

You could always try using alternatives to see if the compression rate is smaller, but chances are, its not a big deal.

If it is the code that is taking a long time, you may consider posting your code on Stack Exchanges' Code Review to see if there is anything that could be improved.


Further, if you are using Python 2.7, you should consider checking out PyInstaller . It is surprisingly easy, however, it has a couple of problems - especially with the PySide Framework - works great for plain PyQt though.

pyinstaller myscript.py --name="MyApp" --onefile

However, for a full list of optional parameters you should really check out the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM