I am trying to execute/call a python script that resides in another directory.
My Problem: When I attempt to open/call the file I get the error
‘..’ is not recognised as an internal or external command, operable
program or batch file
My python code to execute the python file is:
os.system("../test.py abc")
I have also tried this but I get the same error on a DIFFERENT part of the string:
os.system(os.getcwd()+"/../test.py abc")
# results in "c:/users/jim/work products/python/testdir/../test.py abc"
Error:
‘c:/users/jim/work ‘ is not recognised as an internal or external command, operable
program or batch file
In windows you should use ‘..\\executeablename’ to run a program or script in the parent directory, not ‘../’ the unix style.
And, to ensure the script can run property, a ‘python’ is better to be added before the command.
So I think this situation should be:
It has not been tested since I am using linux, you can just try.
BTW, ‘os.system’ is kinda deprecated and the subprocess module is recommend to use when execute system level command.