【发布时间】:2016-12-30 19:37:58
【问题描述】:
我在/Desktop/jsons 目录中有一组 json 文件,并且我有一个 Scala 脚本,它接收一个 json 并输出内容。我可以通过 cding 进入 Scala 脚本 (/Me/dev/scalastuff) 的目录并运行
sbt --error "run /Desktop/jsons/jsonExample.json",
在终端中输出我想要的东西。
我想编写一个 Python 脚本,它会自动执行此操作,并另外输出一个带有 Scala 脚本输出的“东西”的 json 文件。
我现在的问题是使用子处理。当我尝试运行时
BASEDIR = '/Me/dev/scalastuff'
p = subprocess.Popen(['sbt --error "run /Desktop/jsons/jsonExample.json"'], cwd = BASEDIR, stdout = subprocess.PIPE)
out = p.stdout.read()
print out
我收到OSError: [Errno 2] No such file or directory。
我完全不知道为什么会发生这种情况。我是子流程的新手,所以请轻视我!
【问题讨论】:
标签: scala python-2.7 sbt subprocess stdout