Fix: Python Script Arguments Not Passed

by garth on May 4, 2007

Welcome back!

On Windows, you can run a Python script on the PATH simply with its name. These should be equivalent: 

c:>congeal blood

c:>congeal.py blood

c:>python congeal.py blood

If it's not working that way, fixing PATHEXT and correcting the file type associations with ASSOC and FTYPE will usually do the trick: 

c:>set PATHEXT=%PATHEXT%:.PY

c:>ftype Python.File="C:Python25python25.exe" "%1" %*

c:>assoc .py=Python.File

If that still isn't working, try deleting the following registry key:

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.PY

There's plenty of advice about PATHEXT, FTYPE, and ASSOC, but none of the search terms I tried dug up the registry key. I knew there had to be one, because giving FTYPE silly arguments didn't stop the script from being executed. I found the registry key by brute-force searching the registry for .PY. I'm posting this so that someone else can save that hour of hassle.

{ 2 comments }

matt 08.29.09 at 3:00 am

Hey,
Few issues. there aren’t any forward slashes in your example above.
I thought this was my saving grace, as I’ve run into the same problem. the .py script i’m calling wont take my args, unless i give the path to that .py script explicitly.
ie.
this works:
python c:\butter\congeal.py blood
but not this:
congeal blood

I’m using vista biz x64. I’ve tried what you recommended. Nothing’s helping.

-THanks, in advance for any help u can offer.

matt 09.04.09 at 3:31 am

i guess nobody keeps this up to date.

Comments on this entry are closed.