【问题标题】:When Running R Code From Terminal Packages Will Not Load Properly从终端包运行 R 代码时无法正确加载
【发布时间】:2017-04-06 19:06:04
【问题描述】:

我目前正在编写使用 YAML 包创建配置文件的 R 代码。我需要像任何其他代码一样导入和使用某些包,但由于某种原因,当我尝试在我的服务器上运行该程序时,它无法正常工作。我有 4 个我需要的包,但我继续运行代码,只使用 lubridate 以保持输出简短。如果我可以加载 lubridate,我相信我也可以加载其他的。

这是我从终端得到的,然后是我的代码。我知道它有点乱,但我现在只是想让它工作。

终端输出:PS 我不能发布超过 2 个链接,所以我正在削减一些输出

  unable to load shared object '/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so':
  /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so)
ERROR: lazy loading failed for package ‘evaluate’
* removing ‘/nfs/aer/prg/r/lib-linux-x86_64/evaluate’
* restoring previous ‘/nfs/aer/prg/r/lib-linux-x86_64/evaluate’
ERROR: failed to lock directory ‘/nfs/aer/prg/r/lib-linux-x86_64’ for modifying
Try removing ‘/nfs/aer/prg/r/lib-linux-x86_64/00LOCK-lubridate’
* installing *source* package ‘knitr’ ...
** package ‘knitr’ successfully unpacked and MD5 sums checked
** R
** demo
** inst
** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so':
  /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so)
Error : unable to load R code in package ‘knitr’
ERROR: lazy loading failed for package ‘knitr’
* removing ‘/nfs/aer/prg/r/lib-linux-x86_64/knitr’

installation of package ‘knitr’ had non-zero exit status
Error in library(lubridate) : there is no package called ‘lubridate’
Execution halted

代码:

#install.packages('lubridate', repos="http://cran.rstudio.com/")
#install.packages('ggplot2', repos="http://cran.rstudio.com/")
#install.packages('plyr', repos="http://cran.rstudio.com/")
#install.packages('yaml', repos="http://cran.rstudio.com/")


install.packages('lubridate', dependencies = TRUE, repos="http://cran.rstudio.com/")
#install.packages("lubridate", repos="http://cran.rstudio.com/")
#install.packages('ggplot2', dependencies = TRUE, repos="http://cran.rstudio.com/")
#install.packages('plyr', dependencies = TRUE, repos="http://cran.rstudio.com/")
#install.packages('yaml', dependencies = TRUE, repos="http://cran.rstudio.com/")

library(lubridate)
#library(lubridate, lib.loc="Y:/work/anne/bin/R Library")
#library(ggplot2)
#library(plyr)
#library(yaml)
#install.packages("lubridate", repos = "http://cran.rstudio.com/", type="source")
#require(lubridate)
#require(ggplot2)
#require(plyr)
#require(yaml)
#  install.packages("lubridate", repos="C:/Users/hadi/Documents/R/R-3.1.1/library") 
#library("lubridate")
  #install.packages("ggplot2", repos="http://cran.rstudio.com/") 
  #library("ggplot2")
  #install.packages("plyr", repos="http://cran.rstudio.com/") 
  #library("plyr")
  #install.packages("yaml", repos="http://cran.rstudio.com/") 
  #library("yaml")


#install_github("lubridate")
#install_github("ggplot2")
#install_github("plyr")
#install_github("yaml")




#Set Working Directory
#setwd('~/Desktop/Front End Testing/Binning Data')######
#Read Config File
config = yaml.load_file('BinConfig.yaml')
#Create Dataframe of the data
dataframe<-read.csv(config$db$dataframe)
#Filter up to 5 Variables at a time or as few as 1 or even 0 variables
dataframe<-dataframe[which(dataframe[config$db$filter1VarName]>=config$db$filter1greaterthanorequalto),]
dataframe<-dataframe[which(dataframe[config$db$filter1VarName]<=config$db$filter1lessthanorequalto),]
dataframe<-dataframe[which(dataframe[config$db$filter2VarName]>=config$db$filter2greaterthanorequalto),]
dataframe<-dataframe[which(dataframe[config$db$filter2VarName]<=config$db$filter2lessthanorequalto),]
#If you do not need this many filters just leave as is with "#" in front. You will get an error but it does not affect the program
dataframe<-dataframe[which(dataframe[config$db$filter3VarName]>=config$db$filter3greaterthanorequalto),]
dataframe<-dataframe[which(dataframe[config$db$filter3VarName]<=config$db$filter3lessthanorequalto),]
#If you do not need this many filters just leave as is with "#" in front. You will get an error but it does not affect the program
dataframe<-dataframe[which(dataframe[config$db$filter4VarName]>=config$db$filter4greaterthanorequalto),]
dataframe<-dataframe[which(dataframe[config$db$filter4VarName]<=config$db$filter4lessthanorequalto),]
#If you do not need this many filters just leave as is with "#" in front. You will get an error but it does not affect the program
dataframe<-dataframe[which(dataframe[config$db$filter5VarName]>=config$db$filter5greaterthanorequalto),]
dataframe<-dataframe[which(dataframe[config$db$filter5VarName]<=config$db$filter5lessthanorequalto),]
#Best kept small. This way if you have narrow bins you can still hit the min # of bins
xBinSize<-config$db$xMinBinSize;
#This is the number of bins you want provided the xBinSize allows for the number of bins
minXBins<- config$db$minXBins;
stationColors <- rainbow(length(stations));
plotX<-vector('list',length(stations));
plotY<-vector('list',length(stations));
stn<-stations
#dataframe<-subset(dataframe,ZAngSGR0_XI<2.7)
#Absorption_Angstrom_Exponent_BG_PM10


#For our application change these two red lines below to fit the column name you wissh to use. Name must be the same as in the data frame        
rawX <- c(dataframe[paste(c(config$db$XVar), collapse="")][TRUE,1],
        dataframe[paste(c(config$db$XVar), collapse="")][TRUE,1]);        
rawY <- c(dataframe[paste(c(config$db$YVar), collapse="")][TRUE,1],
        dataframe[paste(c(config$db$YVar), collapse="")][TRUE,1]);


dataX <- rawX[!is.na(rawX) & !is.na(rawY)];
dataY <- rawY[!is.na(rawX) & !is.na(rawY)];
# Figure out the bin range and bin size
rX <- range(dataX);
useBinSize <- xBinSize;
    rX[1] <- floor(rX[1] / useBinSize) * useBinSize;
    rX[2] <- ceiling(rX[2] / useBinSize) * useBinSize;
    if ((rX[2] - rX[1]) > useBinSize * minXBins) {
        rX <- range(dataX);
        useBinSize <- (rX[2] - rX[1]) / minXBins;
    }# < useBinSize * minXBins
    nBins <- (rX[2] - rX[1]) / useBinSize ;
    # Bin the data
    bins <- seq(rX[1],rX[2], useBinSize);
    outY <- seq(1,nBins);
    outX <- seq(1,nBins);#bins
    rows<-length(dataX)
    outXBin1<-NULL
    outXBindims=NULL
    for (bin in seq(1,nBins)) {
        outY[bin] <- mean(dataY[dataX>=bins[bin] & dataX<bins[bin+1]],na.rm=T);
        outXBin1[bin] <- as.data.frame(dataX[dataX>=bins[bin] & dataX<bins[bin+1]]);
        outXBindims[bin]<-length(outXBin1[[bin]])

        #outYBinF[,bin] <- (dataY[dataX>=bins[bin] & dataX<bins[bin+1]]);
        outX[bin] <- mean(c(bins[bin], bins[bin+1]));
        #outXBinF[,bin] <- (c(bins[bin], bins[bin+1]));
    }

    plotX <- data.frame(outX[!is.na(outY)]);
    plotY <- data.frame(outY[!is.na(outY)]);
    weight<-data.frame(outXBindims[!is.na(outY)]);
    DF<-cbind(plotX,plotY,weight)
    names(DF)[names(DF)=='outX..is.na.outY..']<-config$db$XVar
        names(DF)[names(DF)=='outY..is.na.outY..']<-config$db$YVar
            names(DF)[names(DF)=='outXBindims..is.na.outY..']<-config$db$Y2Var
                #DF$FrequencyPercent<-(DF[config$db$Y2Var]/(sum(DF[config$db$Y2Var]))*100)
            #names(DF)[names(DF)=='FrequencyPercent']<-c("Frequency Percent")
write.csv(DF,config$db$BinnedDataName)

【问题讨论】:

  • 总是尝试包含一个minimal reproducible example。错误实际发生在哪一行?它似乎正在尝试安装knitrstringi,但这些不是lubridate 的依赖项。我在该错误消息中看到失败的第一个包是“评估”,所以我会尝试先在服务器上安装该包,看看会发生什么。
  • 我相信它在 install.package 失败
  • 我不确定如果我在 Rstudio 中运行它为什么会起作用,但是当我在终端 R --slave -f Bin.R 中运行它时,我得到了那个错误。我尝试了有无依赖关系,有无回购...... IDK怎么办
  • 我也相信我包括了可重现的例子。我给你所有的代码。问题是我在终端上做它失败了
  • 所以如果你的脚本只有第一个 install.packages()library() 你会得到完全相同的错误吗?还是错误发生了变化?您是否有理由不在命令行中使用 Rscript

标签: r terminal install.packages


【解决方案1】:

所以我只用 install.packages() 和 library.... 运行它。这就是我得到的错误:P.S.我没有足够的声誉来发布超过 2 个链接,所以我继续制作 https htps,这样我仍然可以发布整个内容......

                                                                                                                             Installing package into ‘/nfs/aer/prg/r/lib-linux-x86_64’

(因为“lib”未指定) 还安装依赖项'evaluate'、'knitr'

尝试 URL 'htp://cran.rstudio.com/src/contrib/evaluate_0.10.tar.gz'

内容类型 'application/x-gzip' 长度 21914 字节 (21 KB)

已下载 21 KB

尝试 URL 'htp://cran.rstudio.com/src/contrib/knitr_1.15.1.tar.gz'

内容类型 'application/x-gzip' 长度 1027808 字节 (1003 KB)

已下载 1003 KB

尝试 URL 'htp://cran.rstudio.com/src/contrib/lubridate_1.6.0.tar.gz'

内容类型 'application/x-gzip' 长度 317672 字节 (310 KB)

已下载 310 KB

  • 正在安装 source 包“评估”... ** 成功解包“评估”包并检查 MD5 和 ** R ** 为延迟加载准备包 dyn.load(file, DLLpath = DLLpath, ...) 中的错误: 无法加载共享对象“/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so”: /lib64/libc.so.6:找不到版本“GLIBC_2.7”(/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so 需要) 错误:“评估”包延迟加载失败
  • 正在删除“/nfs/aer/prg/r/lib-linux-x86_64/evaluate”
  • 恢复之前的‘/nfs/aer/prg/r/lib-linux-x86_64/evaluate’ 错误:无法锁定目录“/nfs/aer/prg/r/lib-linux-x86_64”进行修改 尝试删除“/nfs/aer/prg/r/lib-linux-x86_64/00LOCK-lubridate”
  • 正在安装 source 包 ‘knitr’ ... ** 包‘knitr’成功解包并检查了 MD5 和 ** R ** 演示 ** 安装 ** 为延迟加载准备包 dyn.load(file, DLLpath = DLLpath, ...) 中的错误: 无法加载共享对象“/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so”: /lib64/libc.so.6:找不到版本“GLIBC_2.7”(/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so 需要) 错误:无法在包“knitr”中加载 R 代码 错误:包“knitr”的延迟加载失败
  • 删除“/nfs/aer/prg/r/lib-linux-x86_64/knitr”

下载的源码包在 '/tmp/RtmpDtWu7K/downloaded_pa​​ckages' 警告信息: 1:在 install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : 软件包“评估”的安装具有非零退出状态 2:在 install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : 软件包“lubridate”的安装具有非零退出状态 3:在 install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : 安装包“knitr”的退出状态非零 库中的错误(lubridate):没有名为“lubridate”的包 执行停止 [气候:/aer/work/anne/bin]$ R --slave -f Bin.r 将软件包安装到“/nfs/aer/prg/r/lib-linux-x86_64” (因为“lib”未指定) 还安装依赖项'evaluate'、'knitr'

尝试 URL 'htp://cran.rstudio.com/src/contrib/evaluate_0.10.tar.gz'

内容类型 'application/x-gzip' 长度 21914 字节 (21 KB)

已下载 21 KB

尝试 URL 'htp://cran.rstudio.com/src/contrib/knitr_1.15.1.tar.gz'

内容类型 'application/x-gzip' 长度 1027808 字节 (1003 KB)

已下载 1003 KB

尝试 URL 'htp://cran.rstudio.com/src/contrib/lubridate_1.6.0.tar.gz'

内容类型 'application/x-gzip' 长度 317672 字节 (310 KB)

已下载 310 KB

  • 正在安装 source 包“评估”... ** 成功解包“评估”包并检查 MD5 和 ** R ** 为延迟加载准备包 dyn.load(file, DLLpath = DLLpath, ...) 中的错误: 无法加载共享对象“/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so”: /lib64/libc.so.6:找不到版本“GLIBC_2.7”(/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so 需要) 错误:“评估”包延迟加载失败
  • 正在删除“/nfs/aer/prg/r/lib-linux-x86_64/evaluate”
  • 恢复之前的‘/nfs/aer/prg/r/lib-linux-x86_64/evaluate’ 错误:无法锁定目录“/nfs/aer/prg/r/lib-linux-x86_64”进行修改 尝试删除“/nfs/aer/prg/r/lib-linux-x86_64/00LOCK-lubridate”
  • 正在安装 source 包 ‘knitr’ ... ** 包‘knitr’成功解包并检查了 MD5 和 ** R ** 演示 ** 安装 ** 为延迟加载准备包 dyn.load(file, DLLpath = DLLpath, ...) 中的错误: 无法加载共享对象“/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so”: /lib64/libc.so.6:找不到版本“GLIBC_2.7”(/nfs/aer/prg/r/lib-linux-x86_64/stringi/libs/stringi.so 需要) 错误:无法在包“knitr”中加载 R 代码 错误:包“knitr”的延迟加载失败
  • 删除“/nfs/aer/prg/r/lib-linux-x86_64/knitr”

下载的源码包在 '/tmp/RtmpJUL44H/downloaded_pa​​ckages' 警告信息: 1:在 install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : 软件包“评估”的安装具有非零退出状态 2:在 install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : 软件包“lubridate”的安装具有非零退出状态 3:在 install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : 安装包“knitr”的退出状态非零 库中的错误(lubridate):没有名为“lubridate”的包 执行停止

感谢您的耐心等待

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-03
    • 1970-01-01
    相关资源
    最近更新 更多