I have a python script that uses subprocess:
import subprocess
print "Running stuff"
subprocess.check_call(["do_stuff.bat"])
print "Stuff run"
If this was named blah.py, and I run (from a command prompt):
python blah.py
I will get the output from do_stuff.bat (or whatever I run).
If this is run as:
blah.py
Then I do not get output from do_stuff.bat, only the print statements.
So far seen on windows Server 2003. Python version 2.5.2 (stuck there for various reasons). Looking at the associated file type action I see:
Python.File="C:\Python25\python.exe" "%1" %*
So can anyone explain the difference?
C:\Python25\python.exe blah.py
do?python blah.py
will find "python" inPATH
andblah.py
will use the file association to find the program to use. These won't necessarily find the same program. Puttingprint sys.version_info
at the top of your script might help debugging too. – Unmeaningftype
won't tell the whole truth as it only reports what's in theHKEY_LOCAL_MACHINE\Software\Classes
which might be overridden by entries inHKEY_CURRENT_USER\Software\Classes
. See my answer to where in the registry does Windows store, with which program to open certain file types? – Orlenareg query HKCU\Software\Classes\Python.File\shell\open\command /ve
andreg query HKLM\Software\Classes\Python.File\shell\open\command /ve
to get the full view. – Orlena