C:\> assoc .py=Python
C:\> ftype Python="C:\python27\python.exe %1 %*"
Or whatever the relevant path is - you can also set command line args using ftype.
In order to make a command recognized without having to give the suffix (.py
), similar to how it works for .exe
files, add .py
to the semi-colon separated list of the (global) PATHEXT
variable.
ETA 2017-07-27
Seems like this is still getting eyeballs, wanted to elevate a useful comment for Win10 users (from @shadowrunner):
For me to get it work under Win10 the actual command was (note the placement of the quotes):
C:\> ftype Python="c:\Anaconda2\python.exe" "%1" %*
ETA 2019-02-01
Talk about evergreen!
First of all, if you're newly installing Python, I highly recommend reviewing the answer by @NunoAndré .
Secondly, to clarify something from a recent comment, please note: you must do both parts (assoc
and ftype
), or use a pre-existing association label in the ftype
command.
By default, at least for Python 3.7 under Windows 8.1, the association for .py
is Python.File
, so performing the ftype
command I wrote above will not work correctly unless the association is first changed. Or you can just use ftype
and give the default association instead. Up to you.