Search code examples
pythonrpremailer

Invoke Python command from R script with System()


In my R script I have to execute an external Python script and I'd use the System() function.

system("python -m premailer -f daily-report.html -o
ready-weekly-report.html")

But after running this in the R console this is what I get

enter image description here

/usr/bin/python: No module named premailer

If I run the python command from the terminal everything works.

EDIT


Solution

  • This is how I fixed this.

    Adding the following line to the end of that file, showed me the correct path in Rstudio after restarting my R kernel:

    .Internal(Sys.setenv("PATH", paste("/usr/local/bin", Sys.getenv("PATH"), sep=":")))