Program Tip

R3.3 용 udunits2 패키지 설치

programtip 2020. 12. 11. 19:18
반응형

R3.3 용 udunits2 패키지 설치


ggforce 및 ggraph 패키지를 설치할 수 있도록 단위 패키지를 설치할 수 있도록 udunits2 패키지를 설치하는 방법을 알아 내려고 하루 종일 낭비했습니다.

ggforce가 R 3.3에서 빌드되었으므로 Ubuntu 16.04 및 R> = 3.3에 설치하려고합니다.

https://github.com/edzer/units/issues/1에서 다음 지침을 따랐습니다.

내 컴퓨터에 libudunits-2.0 및 udunits가 설치되어 있지만 (sudo apt-get install udunits2는 udunits2 패키지를 찾지 못함) 내 $ PATH에있는 libudunits-2 및 udunits 위치에 대한 PATH, 시도 할 때 R에서 udunits2, units 또는 ggforce를 설치하면 다음과 같은 오류가 발생합니다.

--* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking for ut_read_xml in -ludunits2... no
-----Error: libudunits2.a not found-----
     If the udunits2 library is installed in a non-standard location,
     use --configure-args='--with-udunits2-lib=/usr/local/lib' for   
     example,
     or --configure-args='--with-udunits2-include=/usr/include/udunits2'
     replacing paths with appropriate values for your installation.
     You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
     environment variables.
     If udunits2 is not installed, please install it.
     It is required for this package.
     ERROR: configuration failed for package ‘udunits2’
* removing ‘/home/fjay/R/x86_64-pc-linux-gnu-library/3.3/udunits2’
* restoring previous ‘/home/fjay/R/x86_64-pc-linux-gnu-library 
/3.3/udunits2’

The downloaded source packages are in
    ‘/tmp/Rtmp0syxnJ/downloaded_packages’
Warning message:
In install.packages("udunits2", lib = "/home/fjay/R/x86_64-pc-linux-
 gnu-library/3.3") :
 installation of package ‘udunits2’ had non-zero exit status
>

So, umm, it's looking for the udunits2.h and libudunits2.a files.... So, I downloaded udunits2 from CRAN, unpacked it and put it in my R library. Then, if I put library(udunits2, lib.loc = "my library dir") I get an error saying it's not installed. So, when I install.package('udunits2', repo = NULL, libconfig.args = '--with-udunits2-lib=/home/fjay/R/x86_64-pc-linux-gnu-library/3.3') or install.packages('units',....) or install.packages('ggforce',...) it is still looking for these files...and, after inspection of the udunits2 package these files are not in any of the udunits2 folders.

If anyone knows how to install this udunits2 packages please help me!


I had the same problem. Following the first answer from here you have to install -dev version of udunits:

sudo apt-get install libudunits2-dev

Then the installation of udunits2 and ggforce goes without any error.

EDIT:

Following the comments below, for CentOS7 it should be:

sudo yum install udunits2-devel

And for MacOS:

brew install udunits

I have installed the udunits2 package in R on the Linux platform (redhat) without Internet connnection.

I also had this problem.

Firstly, I installed the udunits2 (not the R package udunits2)in the Linux example at (/usr/include/udunits2).

Secondly, running this command worked: install.packages("udunits2_0.13.tar.gz",configure.args='--with-udunits2-include=/usr/include/udunits2')

I hope this experience could help you.


This won't be any help to the chap that asked the question, but I was just having the same issue on a computing cluster without root access and the following worked:

homedir <- Sys.getenv("HOME")
udunits_dir <- file.path(Sys.getenv("HOME"), "udunits")
system(paste0("mkdir ", udunits_dir))
system(paste0("wget --directory-prefix=", udunits_dir, " ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.2.25.tar.gz"))
owd <- getwd()
setwd(udunits_dir)
system("tar xzvf udunits-2.2.25.tar.gz")
setwd(file.path(udunits_dir, "udunits-2.2.25"))
system(paste0("./configure --prefix=", udunits_dir, "/local"))
system("make")
system("make install")
setwd(owd)
Sys.setenv(LD_LIBRARY_PATH=paste0(Sys.getenv("LD_LIBRARY_PATH"), ":", udunits_dir, "/local/lib"))
install.packages("udunits2", 
                 type = "source",
                 configure.args = c(paste0("--with-udunits2-include=", udunits_dir, "/local/include"), 
                                    paste0("--with-udunits2-lib=", udunits_dir, "/local/lib")),
                 repos = "http://cran.rstudio.com")
dyn.load(paste0(udunits_dir, "/local/lib/libudunits2.so.0"))
install.packages("units", repos = "http://cran.rstudio.com")

참고URL : https://stackoverflow.com/questions/42287164/install-udunits2-package-for-r3-3

반응형