2

I am trying to run an R script from PHP.

My PHP file looks like this:

exec("Rscript fig_lollipop.r");

And my R script looks like this:

library('RPostgreSQL')
#more goes code here...

I keep getting the following error:

Error in library("RPostgreSQL"):There is no package called 'RPostgreSQL'

I have attempted searching for common answers to this, and I think it might be related to the www-data user, but I'm really not sure. The R script works fine when running from the terminal.

Thanks in advance for any help! RC

3
  • I forgot to mention that I am working on Ubuntu 12.04. Commented May 30, 2014 at 22:25
  • Can you change your script to show the value of .libPaths() for that session so that you know the web user can see the package? Do they have permissions to read those files? Commented May 30, 2014 at 22:44
  • 1
    The .libPaths() command in the terminal revealed an additional folder (where all the relevant packages are stored), as compared to .libPaths() from the web app. I copied the needed packages to a folder listed in .libPaths() from the web app, and now everything works. Thanks for the advice! Commented Jun 10, 2014 at 20:39

1 Answer 1

2

I ran the .libPaths() command in the terminal, and discovered an additional folder (where all of the relevant packages are stored), as compared to the .libPaths() command run from the web app. I ended up copying relevant packages to a folder listed in the web app .libPaths(), and everything works now.

Thanks to "MrFlick" for the advice! I'm a newbie to this stuff, and thought that packages were installed for all users.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.