I have a set of json files in directory
sbt --error "run /Desktop/jsons/jsonExample.json"
BASEDIR = '/Me/dev/scalastuff'
p = subprocess.Popen(['sbt --error "run /Desktop/jsons/jsonExample.json"'], cwd = BASEDIR, stdout = subprocess.PIPE)
out = p.stdout.read()
OSError: [Errno 2] No such file or directory
popen in python takes a list of shell arguments. You're passing only one!
So it's trying to execute a file named wholly
'sbt --error "run /Me/Desktop/jsons/jsonExample.json"'.
Obviously, this doesn't work.
If you use
popen; only pass a simple array -- you needn't care about escaping:
subprocess.popen(['sbt', '--error', 'run /Me/Desktop/...'], cwd = BASEDIR, stdout = subprocess.PIPE)