Jonathan Kittell
Jonathan Kittell

Reputation: 7493

How to ensure Python script runs by double clicking on Windows OS

I have two Windows 7 machines. On one machine I can run python scripts by double clicking on the .py file, however on the other machine the script does not execute, the command prompt will flash quickly and the script does not execute. I can execute scripts on both machines using the command line. I have the same version of python installed on both machines.

How do I ensure that a python script can be executed by double clicking the script on Windows 7?

Upvotes: 2

Views: 3966

Answers (1)

Albert H
Albert H

Reputation: 159

Step 1. Check if your .py files are associated with "python launcher" (Not just "python"). You can check that by right clicking the .py file and see:

on Windows 10

In my case, I have two machines of Windows 10. The one with Python 3.6 installed by choosing "Install Now" works perfectly. The another one which having the same version of python installed in a customized location has problems. It seems nothing to do with the environment path setting, as I could run python in the console mode correctly. So at the end, I was forced to uninstall the python, (then removing all the related paths manually if needed), and install it again with default setting "Install Now".

Upvotes: 1

Related Questions