【问题标题】:Can't load R library on server using Rscript command无法使用 Rscript 命令在服务器上加载 R 库
【发布时间】:2014-10-31 09:16:19
【问题描述】:

我正在使用 perl-cgi 调用

my $call = qx(Rscript tcga_analysis.R $bg_name $ctr_name $set $user);

当我在服务器上使用来自 unix 的 Rscript myRscript.R 时,它可以工作,但从 perl 中我似乎无法加载任何包。我收到以下错误(来自 Apache 日志):

Error in library(gplots) : there is no package called 'gplots'

使用 .libPaths():

> .libPaths()
[1] "/home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1"
[2] "/usr/lib64/R/library"
[3] "/usr/share/R/library"

在主文件夹中显示我的个人图书馆。

我尝试过使用

library(gplots, lib.loc="/home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1")

但我收到lib.loc error 说那里没有图书馆树。 我什至在包含库路径的工作目录中创建了一个.Rprofile 文件,但没有成功。我也尝试添加pos=1,但没有成功...

但是,如果我打开 R 并调用 library(gplots) 它可以工作

我需要让它从 perl 调用 Rscript,因为它是分析管道的一部分,它使用 Web 界面 -> perl-cgi -> R 来分析一些数据!

谢谢:)

【问题讨论】:

  • cgi 脚本是否由其他用户运行,可能是 apache?可能是权限问题。
  • 我是包含 R 和 perl cgi 脚本的 var/www/html 文件夹的所有者
  • R 库的权限似乎是个问题。试试chmod -R a+r /home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1,即让任何人都可以阅读所有内容。
  • @flodel 刚试过,日志上同样的错误:Error in library(gplots) : there is no package called 'gplots'
  • 能否提供以自己身份运行ls -ld /home/sbattaglia/R/x86_64-redhat-linux-gnu-library/3.1/gplots的输出?

标签: r gplots


【解决方案1】:

我将发布与@floded 聊天中出现的答案。

基本上,这些库位于服务器上对 Apache 不可见的文件夹中。 我在 .R 和 .cgi 文件所在的位置重新下载了我需要的包,指定了 library(gplots, lib.loc="correctPathToLibrary") 并且它工作了:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    • 2021-10-11
    • 2016-04-06
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多