I am trying to run an R script from Python. The Rscript train.R
is in the same folder as the Jupyter Notebook. The working directory is set to that folder.
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)
I am getting a CalledProcessError:
None
1
Command '['Rscript', 'train.R']' returned non-zero exit status 1
None
I tried to set the argument shell=True
and I tried to set the argumentcwd=os.path.dirname(os.path.realpath("train.R"))
as mentioned here.
The command Rscript train.R
works just fine if I open a console in the folder.
What am I doing wrong?