我有一个R脚本,可以制作几个图.我希望能够从python执行此脚本.
我第一次尝试:
import subprocess
subprocess.call("/.../plottingfile.R", shell=True)
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
/bin/sh: /.../plottingfile.R: Permission denied
126
Run Code Online (Sandbox Code Playgroud)
我不知道126号的含义是什么.我的所有文件都在桌面上,因此我认为不需要任何特殊权限?我认为这个错误可能与cwd = none有关但我改变了这个并且我仍然有错误.
接下来我尝试了以下内容:
subprocess.Popen(["R --vanilla --args </.../plottingfile.R>"], shell = True)
Run Code Online (Sandbox Code Playgroud)
但这也给了我一个错误:
/bin/sh: Syntax error: end of file unexpected.
Run Code Online (Sandbox Code Playgroud)
最近我尝试过:
subprocess.Popen("konsole | /.../plottingfile.R", shell = True)
Run Code Online (Sandbox Code Playgroud)
这打开了一个新的konsole窗口但没有运行R脚本.另外,我收到以下错误:
/bin/sh: /.../plottingfile.R: Permission denied
Run Code Online (Sandbox Code Playgroud)
谢谢.