简体   繁体   中英

When Running R Code From Terminal Packages Will Not Load Properly

I am currently working on an R code that uses the YAML package to create a config file. I need to import and use certain packages like any other code but for some reason when I try to run the program on my server at work it does not work properly. I have 4 packages I need but I went ahead an ran the code with just lubridate to keep the output short. If I can load lubridate I am sure I can load the others too.

Here is what I get from the terminal and after that is my code. I know its a bit messy but I am just trying to get it to work right now.

Terminal output: PS I cant post more than 2 links so I am cutting the output some

  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

Code:

#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)

So I ran it with just install.packages() and library.... This is what I got as the error: PS I do not have enough reputation to post more than 2 links so I went ahead and make the https htps instead so I can still post the entire thing...

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

(as 'lib' is unspecified) also installing the dependencies 'evaluate', 'knitr'

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

Content type 'application/x-gzip' length 21914 bytes (21 KB)

downloaded 21 KB

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

Content type 'application/x-gzip' length 1027808 bytes (1003 KB)

downloaded 1003 KB

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

Content type 'application/x-gzip' length 317672 bytes (310 KB)

downloaded 310 KB

  • installing source package 'evaluate' ... ** package 'evaluate' successfully unpacked and MD5 sums checked ** R ** 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: 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'

The downloaded source packages are in '/tmp/RtmpDtWu7K/downloaded_packages' Warning messages: 1: In install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : installation of package 'evaluate' had non-zero exit status 2: In install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : installation of package 'lubridate' had non-zero exit status 3: In install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : installation of package 'knitr' had non-zero exit status Error in library(lubridate) : there is no package called 'lubridate' Execution halted [climate:/aer/work/anne/bin]$ R --slave -f Bin.r Installing package into '/nfs/aer/prg/r/lib-linux-x86_64' (as 'lib' is unspecified) also installing the dependencies 'evaluate', 'knitr'

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

Content type 'application/x-gzip' length 21914 bytes (21 KB)

downloaded 21 KB

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

Content type 'application/x-gzip' length 1027808 bytes (1003 KB)

downloaded 1003 KB

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

Content type 'application/x-gzip' length 317672 bytes (310 KB)

downloaded 310 KB

  • installing source package 'evaluate' ... ** package 'evaluate' successfully unpacked and MD5 sums checked ** R ** 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: 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'

The downloaded source packages are in '/tmp/RtmpJUL44H/downloaded_packages' Warning messages: 1: In install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : installation of package 'evaluate' had non-zero exit status 2: In install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : installation of package 'lubridate' had non-zero exit status 3: In install.packages("lubridate", dependencies = TRUE, repos = "htp://cran.rstudio.com/") : installation of package 'knitr' had non-zero exit status Error in library(lubridate) : there is no package called 'lubridate' Execution halted

Thank you for your patience

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM