• Program's MS-DOS windows disappears.
    18 replies, posted
The program works fine within Python's shell, but when I compile it into an exe with py2exe, the MS-DOS window always disappears before I can do anything. How do I fix this? Here's the [url=http://www.filefactory.com/file/ah65dhc/n/Degrees_Conversion_exe][B]program.[/B][/url] Requested source code. [code]def START(): Celsius = input('Degrees in Celsius:'); Fahrenheit = (9.0 / 5.0) * Celsius +32; print Celsius, "Degree(s) Celsius =", Fahrenheit, "Degree(s) Fahrenheit",[/code] Very simple program I wrote for classmates, but seeing as most of them don't have Python I used py2exe to turn it into an executable, but that didn't exactly work....
getchar() or whatever it's equivalent is in python Isn't there a sticky or something that says this? You people ask this question at least once a month, and it never seems to stick.
[QUOTE=Cathbadh;17184693]getchar() or whatever it's equivalent is in python Isn't there a sticky or something that says this? You people ask this question at least once a month, and it never seems to stick.[/QUOTE] No, there isn't. If you had read the one and only sticky here, you would know it has nothing to do with Python other than mentioning it exists.
It's not MS-DOS, it's just a cmd.exe window.
Please source code instead of executable... For all we know it could be a trojan.. plus unless we decompile your executable theres no way to see what you did wrong
What Cathbadh is trying to say is that the application doesn't know to pause for you before it quits, even though that's what you expect.
That was what i originally wrote.. But then i looked at the name of the program and figured that it probably expected user input at some point..
[QUOTE=Noisy Spy;17184473]The program works fine within Python's shell, but when I compile it into an exe with py2exe, the MS-DOS window always disappears before I can do anything. How do I fix this?[/QUOTE] Easiest fix is to open up a command prompt and run the program from there, rather than double-clicking its icon. Needs no altering of the script's source.
Console applications are meant to be run by the command line... which is why they close if you click them.
[QUOTE=TehDoomCat;17250710]Easiest fix is to open up a command prompt and run the program from there, rather than double-clicking its icon. Needs no altering of the script's source.[/QUOTE] Thank you good sir. [editline]10:51AM[/editline] Well that didn't work, and google hasn't correctly answered what Python's getchar() equivalent is... [editline]10:53AM[/editline] [code]def START(): Celsius = input('Degrees in Celsius:'); Fahrenheit = (9.0 / 5.0) * Celsius +32; print Celsius, "Degree(s) Celsius =", Fahrenheit, "Degree(s) Fahrenheit",[/code] Very simple program I wrote for classmates, but seeing as most of them don't have Python I used py2exe to turn it into an executable, but that didn't exactly work....
Try raw_input()
(Noisy Spy alt) Screw it, going back to C++ and mah [code] system( "PAUSE" ); return 0;[/code]
Who compiles py into exes? :raise:
[QUOTE=PvtCupcakes;17541236]Who compiles py into exes? :raise:[/QUOTE] People who are mad that Python programs can only be run with Python. (It'd be okay if Python came with all computers like Java, but it doesn't.)
[QUOTE=Solid.Snake;17541735]People who and are mad that Python programs can only be run with Python. (It'd be okay if Python came with all computers like Java, but it doesn't.)[/QUOTE] Does the exe bundle the the python interpreter into them?
[QUOTE=PvtCupcakes;17541770]Does the exe bundle the the python interpreter into them?[/QUOTE] What? I'm going to go ahead and say no....
Actually, that's exactly what it does. py2exe is not a compiler.
If you mean that it knows to pause at inputs and outputs in the executable like it does in Python, as I found out no. [editline]04:22PM[/editline] Broke mah Automerge
[QUOTE=Noisy Spy;17288098]Thank you good sir. [editline]10:51AM[/editline] Well that didn't work, and google hasn't correctly answered what Python's getchar() equivalent is... [editline]10:53AM[/editline] [code]def START(): Celsius = input('Degrees in Celsius:'); Fahrenheit = (9.0 / 5.0) * Celsius +32; print Celsius, "Degree(s) Celsius =", Fahrenheit, "Degree(s) Fahrenheit",[/code] Very simple program I wrote for classmates, but seeing as most of them don't have Python I used py2exe to turn it into an executable, but that didn't exactly work....[/QUOTE] Please try this: [code] def START(): Celsius = input('Degrees in Celsius:'); Fahrenheit = (9.0 / 5.0) * Celsius +32; print Celsius, "Degree(s) Celsius =", Fahrenheit, "Degree(s) Fahrenheit" START() [/code] You have defined a function but you never initialized it :) Also you can ask for the user to input text or press a key after your print Celsius statement. But console windows are normally closed after their completion. EndText = input("Enter any text to continue then press enter")
Sorry, you need to Log In to post a reply to this thread.