为R3.3安装udunits2软件包

use*_*338 59 r

我只是浪费了一整天试图找出如何安装udunits2包以便能够安装单元包以便能够安装ggforce和ggraph包.

我正在尝试在Ubuntu 16.04上安装它,并且R> = 3.3,因为ggforce是在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,当我尝试时安装udunits2,单位或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
>
Run Code Online (Sandbox Code Playgroud)

所以,嗯,它正在寻找udunits2.h和libudunits2.a文件....所以,我从CRAN下载了udunits2,将其解压缩并将其放入我的R库中.然后,如果我把库(udunits2,lib.loc ="我的库目录")我得到一个错误,说它没有安装.所以,当我install.package('udunits2',repo = NULL,libconfig.args =' - with-udunits2-lib =/home/fjay/R/x86_64-pc-linux-gnu-library/3.3')或install.packages('units',....)或install.packages('ggforce',...)它仍在寻找这些文件......并且,在检查了udunits2包之后,这些文件都没有的udunits2文件夹.

如果有人知道如何安装这个udunits2包请帮助我!

pot*_*kan 105

我有同样的问题.从这里得到第一个答案后你必须安装以下-dev版本udunits:

sudo apt-get install libudunits2-dev
Run Code Online (Sandbox Code Playgroud)

然后安装udunits2ggforce没有任何错误.

编辑:

根据以下评论,对于CentOS7,它应该是:

sudo yum install udunits2-devel
Run Code Online (Sandbox Code Playgroud)

而对于MacOS:

brew install udunits
Run Code Online (Sandbox Code Playgroud)

  • 在CentOS7上,应该是`sudo yum install udunits2-devel`. (5认同)
  • 当这个_awesome_答案救了我的时候,我正处于与OP相同的路线("我只是浪费了一整天......")的边缘. (2认同)
  • 在Mac OS XI上,只需要做'brew install udunits` (2认同)

小智 9

我已经udunits2在Linux平台(redhat)上的R中安装了软件包而没有Internet连接.

我也有这个问题.

首先,我在udunits2()的Linux示例中安装了(而不是R包udunits2 /usr/include/udunits2).

其次,运行此命令有效: install.packages("udunits2_0.13.tar.gz",configure.args='--with-udunits2-include=/usr/include/udunits2')

我希望这次经历可以帮到你.

  • 第二个命令可能应该是`install.packages("udunits2",configure.args =' - with-udunits2-include =/usr/include/udunits2')`no udunits version(udunits2_0.13.tar.gz not available)对于最新版本的R).这对Fedora 26来说很有用. (3认同)

Flo*_*rag 7

这对提出问题的人没有任何帮助,但我只是在没有 root 访问权限的计算集群上遇到了同样的问题,以下工作正常:

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",
             configure.args = c(paste0("--with-udunits2-include=", udunits_dir, "/local/include"), 
                                paste0("--with-udunits2-lib=", udunits_dir, "/local/lib")))
Run Code Online (Sandbox Code Playgroud)