在RStudio - Ubuntu 16.04中安装R包的问题

时间:2022-01-01 23:41:43

I'm running R and RStudio on Ubuntu 16.04 64-bit, and am trying to do clustering analysis, though I think my error is not specific to this package... But when I try to install the package 'ClusterR' from CRAN, I get the following error.

我在Ubuntu 16.04 64位上运行R和RStudio,并且正在尝试进行聚类分析,尽管我认为我的错误并不是针对这个包的。但是,当我试图从CRAN安装包“ClusterR”时,我得到了以下错误。

> install.packages("ClusterR")
Installing package into ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘tiff’, ‘OpenImageR’, ‘gmp’

trying URL 'https://cran.rstudio.com/src/contrib/tiff_0.1-5.tar.gz'
Content type 'application/x-gzip' length 28925 bytes (28 KB)
==================================================
downloaded 28 KB

trying URL 'https://cran.rstudio.com/src/contrib/OpenImageR_1.0.6.tar.gz'
Content type 'application/x-gzip' length 802641 bytes (783 KB)
==================================================
downloaded 783 KB

trying URL 'https://cran.rstudio.com/src/contrib/gmp_0.5-13.1.tar.gz'
Content type 'application/x-gzip' length 131321 bytes (128 KB)
==================================================
downloaded 128 KB

trying URL 'https://cran.rstudio.com/src/contrib/ClusterR_1.0.5.tar.gz'
Content type 'application/x-gzip' length 916490 bytes (895 KB)
==================================================
downloaded 895 KB

* installing *source* package ‘tiff’ ...
** package ‘tiff’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c common.c -o common.o
In file included from common.c:1:0:
common.h:5:18: fatal error: tiff.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'common.o' failed
make: *** [common.o] Error 1
ERROR: compilation failed for package ‘tiff’
* removing ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4/tiff’
Warning in install.packages :
  installation of package ‘tiff’ had non-zero exit status
* installing *source* package ‘gmp’ ...
** package ‘gmp’ successfully unpacked and MD5 sums checked
creating cache ./config.cache
checking for __gmpz_ui_sub in -lgmp... no
configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org
ERROR: configuration failed for package ‘gmp’
* removing ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4/gmp’
Warning in install.packages :
  installation of package ‘gmp’ had non-zero exit status
ERROR: dependency ‘tiff’ is not available for package ‘OpenImageR’
* removing ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4/OpenImageR’
Warning in install.packages :
  installation of package ‘OpenImageR’ had non-zero exit status
ERROR: dependencies ‘OpenImageR’, ‘gmp’ are not available for package ‘ClusterR’
* removing ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4/ClusterR’
Warning in install.packages :
  installation of package ‘ClusterR’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpuIo1WM/downloaded_packages’

And indeed, if I try installing just the package 'tiff' I get the same error, distilled here:

实际上,如果我试着只安装一个“tiff”包,我也会得到相同的错误,在这里提炼:

Installing package into ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/tiff_0.1-5.tar.gz'
Content type 'application/x-gzip' length 28925 bytes (28 KB)
==================================================
downloaded 28 KB

* installing *source* package ‘tiff’ ...
** package ‘tiff’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c common.c -o common.o
In file included from common.c:1:0:
common.h:5:18: fatal error: tiff.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'common.o' failed
make: *** [common.o] Error 1
ERROR: compilation failed for package ‘tiff’
* removing ‘/home/daniel/R/x86_64-pc-linux-gnu-library/3.4/tiff’
Warning in install.packages :
  installation of package ‘tiff’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpuIo1WM/downloaded_packages’

I'm still somewhat of a coding newbie, both with R and Ubuntu, so I'm not sure what I'm missing here? I have a feeling that I'm missing some dependency/library in Ubuntu that is needed for installing from source this way in R but I'm not sure what? And I haven't had trouble installing other packages from source, including even other packages loaded with 'ClusterR'.

我还是一个编程新手,有R和Ubuntu,所以我不确定我在这里漏掉了什么?我有一种感觉,我在Ubuntu中丢失了一些依赖/库,这些依赖/库是用这种方式在R中从源代码中安装所需要的,但是我不确定是什么?而且我还没有遇到从源代码中安装其他包的麻烦,包括其他包含“ClusterR”的包。

I have GCC Fortran installed, terminal code listed here:

我已经安装了GCC Fortran,终端代码列在这里:

daniel@fulgur-desktop:~$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 个解决方案

#1


2  

R packages often has external system dependencies that usually cannot be installed through R. If you check the CRAN package docs for the tiff package it mentions tiff and jpeg libraries are required. Anyway, looking around on Ubuntu package list and making a search for tiff leads to the libtiff5-dev package. Run

R包通常具有外部系统依赖项,这些依赖项通常无法通过R安装。无论如何,在Ubuntu包列表中查找并搜索tiff会导致libtiff5-dev包。运行

sudo apt-get install libtiff5-dev

And you should be fine. As a heads up, for installing system requirements for an R package, you usually want to install the version with -dev at the end.

你应该没事的。注意,要安装R包的系统需求,通常需要在末尾安装带有-dev的版本。

#1


2  

R packages often has external system dependencies that usually cannot be installed through R. If you check the CRAN package docs for the tiff package it mentions tiff and jpeg libraries are required. Anyway, looking around on Ubuntu package list and making a search for tiff leads to the libtiff5-dev package. Run

R包通常具有外部系统依赖项,这些依赖项通常无法通过R安装。无论如何,在Ubuntu包列表中查找并搜索tiff会导致libtiff5-dev包。运行

sudo apt-get install libtiff5-dev

And you should be fine. As a heads up, for installing system requirements for an R package, you usually want to install the version with -dev at the end.

你应该没事的。注意,要安装R包的系统需求,通常需要在末尾安装带有-dev的版本。