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?
The python command is the standard installed alias for python2 or python3. the py command is a non-standard command line tool which seem to invoke Python3 by default and gives command line access to python constructs . The py command uses it's own method for identifying which python version to use.
On recent versions of Windows, it is possible to run Python scripts by simply entering the name of the file containing the code at the command prompt: C:\devspace> hello.py Hello World!
When you installed Python, you didn't check the box to add it to your PATH , which is why it isn't there. In general, it's best to use the Windows Python Launcher, py.exe anyway, so this is no big deal. Just use py for launching consistently, and stuff will just work.
I had common problem using threads, but all of my code was in python. Threads can not write to standard output using print. Just main thread could do that. I used somethnig like this
import sys
sys.stdout.write("this was printed by thread")
I know that probably it wont help you with bat file...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With