I try to open a python file, but it immediately closes after its opened, Anybody know how to fix this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I try to open a python file, but it immediately closes after its opened, Anybody know how to fix this?

Just wanna know.

18th Aug 2020, 7:25 PM
Onyxle
Onyxle - avatar
5 Answers
+ 6
Can you save that code here in SoloLearn and share the code link for analysis? Idk for sure, but does it help if you add an input() call at the end of the code, just so the code waits for input before exiting?
18th Aug 2020, 7:49 PM
Ipang
+ 1
If you're on Windows change extension to .pyw, it should make the window persist
18th Aug 2020, 7:28 PM
Steven M
Steven M - avatar
+ 1
Ipang's or Steven's fix should work. But on windows i use batch files with "@pause" as the last line. This also pauses the window so you can see the output without changing the code directly https://datatofish.com/batch-JUMP_LINK__&&__python__&&__JUMP_LINK-script/
19th Aug 2020, 1:01 AM
Slick
Slick - avatar
0
Now it doesn't show up at all.
18th Aug 2020, 7:36 PM
Onyxle
Onyxle - avatar
0
Open Command Prompt and run the file through Command Prompt
18th Aug 2020, 7:39 PM
Steven M
Steven M - avatar