Skip to content Skip to sidebar Skip to footer

Double-clicking Foo.py In Win. Explorer Doesn't Work While Other Running Methods Do.

Short answer: If absence of input() in the end of the file is not the case, then double-tripple-quadripple check what version of Python is trying to run your script when double-cli

Solution 1:

However it doesn't work if run by double-clicking in win. explorer. Command line window pops up, flashes - and it's gone.

This is normal under Windows, you need to put input at the end of your script if you want the Command Prompt window to stay until you hit enter key. Once your console program executes and reaches the end-of-file where you have nothing left, it just exits, this is by default under Windows.

What could possibly cause this? I am sure that file association is set correctly and double clicking causes C:\Python\Python 3.5.3\python.exe to open .py files. What's the difference between running .py from command line and running them from win. explorer?

*If you have Python Windows Launcher installed in your Windows machine, clicking on files will run py.exe and this executable will determine the right python.exe to run your script with, except if you changed the file association from Windows to run python.exe directly or if you've chosen not to install the launcher all together. The big difference is that, Windows File Explorer may or may not run python.exe, you have to double check that in Windows, while in Command Prompt when you type: python.exe myscript.py executes myscript.py with python.exe. Typically Windows will find python.exe from the environment variable PATH.

Try to click on this script and see what happens:

#myscript.pyinput("Press enter to exit")

The console window should stay when you click on this script file.

Post a Comment for "Double-clicking Foo.py In Win. Explorer Doesn't Work While Other Running Methods Do."