我正在尝试从Python运行R脚本。 Rscript train.R
与Jupyter Notebook在同一文件夹中。工作目录已设置到该文件夹。
import subprocess
try:
subprocess.check_call(['Rscript', 'train.R'], shell=False)
except subprocess.CalledProcessError as e:
print(e.output)
print(e.returncode)
print(e)
print(e.stderr)
我收到CalledProcessError:
None
1
Command '['Rscript', 'train.R']' returned non-zero exit status 1
None
我尝试设置参数shell=True
,并尝试设置参数cwd=os.path.dirname(os.path.realpath("train.R"))
,如here.所述>
如果我在文件夹中打开控制台,则命令Rscript train.R
可以正常工作。
我在做什么错?
我正在尝试从Python运行R脚本。 Rscript train.R与Jupyter Notebook在同一文件夹中。工作目录设置为该文件夹。导入子流程尝试:子流程....
我建议您改用Popen