Search code examples
pythonpython-3.xwindowslauncher

Python launcher keeps crashing


I have recently deleted python 3.8.1 and decided to keep using python 3.7.4

However, I am speculating that the python launcher keeps crashing because it is using the deleted python version. When I try to open the file with python 3.7.4 by right clicking then going to the python idle and running the file using it, it doesn't crash. But, when I double click the file to run it, the python launcher crashes.

How can I fix that problem ?


Solution

  • After installing python and the py.exe launcher with the installer from python.org, double clicking a .py file should run the file with py.exe, which will run the file with python.exe in a new console window. If there is more than one python.exe (say 3.7.u and 3.8.v), py.exe selects the last one with 'make this default' checked during installation. Or it selects the most recent version. One can determine the current default by running 'py' at a Command Prompt command line and checking the first line of the interactive message.

    When python finishes executing the file, it exits and the new window closes. For a typical beginner file, this takes less than a second, especially if there is an error and traceback on startup. In any case, one likely will never see any output. I suspect that this is what you are calling a 'crash'. If so, everything is working as designed.

    To prevent the window from closing, prevent python from existing by adding a blocking function call such as input('Hit return to exit: ') at or near the end. For a tkinter program, root.mainloop() blocks until the tkinter window is closed.

    To see what the program outputs without editing it, run it in Command Prompt. py path-to-something.py.