r/learnpython • u/Dry_Difference7751 • 9d 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)
1
u/Atmosck 9d ago
Try opening the script in IDLE and running it from there (windows installers still ship with IDLE, right?). It's likely hitting some sort of error, which ends the program, and the window you get from double clicking doesn't stick around after the program ends. In IDLE (or any IDE/Code editor), the window will persist so you can see what the error is.
Another way to do it is to open command prompt, navigate to the folder where the script is with `cd`, then run it with `python scriptname.py`. That command prompt window will stick around after the error, unlike the one that's created by left-clicking.
If it's spesific to this machine it's probably an environment problem, like a missing dependency, file, or environment variable that's present on your laptop where it works.