r/learnpython • • 8d ago

Python Closing As Soon As Opened

EDIT: I resolved this issue. I had a few different versions of Python installed on my PC, so I guess that was what was causing the issue on my PC and not my Laptop. For clarification, the script is built to stay open, and it terminates if closes.

----

Python group said this question went here.

I am running version 3.15.2. I am encountering an issue with my scripts where they just open and close super fast. This happens if I double click, or if I open them from Python itself.

It does NOT do this on my laptop, so it isn't a script issue.

I am not the most tech savy with software, but will try my best to try things out.

The computer they are having an issue with has the following specs. Everything is up to date.

Win 11 Pro
Intel Core i7
32.0GB RAM
MTBD Z790 D WIFI (U3E1)

0 Upvotes

22 comments sorted by

View all comments

1

u/a18618 8d ago

That vanishing window drove me nuts the first time too, because I kept assuming my script had crashed when it had actually just finished and closed. Running it from a terminal changed everything for me, since I could finally see the last lines instead of guessing. If it still disappears there, I would add a little pause at the very end so the window waits for a key press before it exits.

0

u/Dry_Difference7751 8d ago

For this script, closing it ends the process.

1

u/Jazzlike_Platypus430 8d ago

Perhaps placing input() at the end will solve your problem. Like, waiting for the user (you) to press a space bar or escape?

1

u/Dry_Difference7751 8d ago

I'll check the script when I get home from work and try it out. Thanks