无法在 Ubuntu 16.04 上安装 mclust R 包

无法在 Ubuntu 16.04 上安装 mclust R 包

我无法在 Ubuntu 16.04 上安装“mclust”R 包。我遇到以下问题:

> install.packages("mclust")

>Installing package into ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.4’
>(as ‘lib’ is unspecified)
>trying URL 'https://cloud.r-project.org/src/contrib/mclust_5.4.2.tar.gz'
>Content type 'application/x-gzip' length 2699941 bytes (2.6 MB)
>==================================================
>downloaded 2.6 MB

>* installing *source* package ‘mclust’ ...
>** package ‘mclust’ 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 init.c -o init.o
>gfortran   -fpic  -g -O2 -fstack-protector-strong  -c mclust.f -o mclust.o
>gfortran   -fpic  -g -O2 -fstack-protector-strong  -c mclustaddson.f -o mclustaddson.o
>g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o mclust.so init.o mclust.o mclustaddson.o -llapack -lblas -lgfortran
-lm -lquadmath -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
>/usr/bin/x86_64-linux-gnu-ld: /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a(memory.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
>/usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a: error adding symbols: Bad value
>collect2: error: ld returned 1 exit status
>/usr/share/R/share/make/shlib.mk:6: recipe for target 'mclust.so' failed
>make: *** [mclust.so] Error 1
>ERROR: compilation failed for package ‘mclust’
>* removing ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.4/mclust’
>Warning in install.packages :
>  installation of package ‘mclust’ had non-zero exit status

>The downloaded source packages are in
>   ‘/tmp/Rtmppg0XWs/downloaded_packages’

>sessionInfo()

>R version 3.4.4 (2018-03-15)
>Platform: x86_64-pc-linux-gnu (64-bit)
>Running under: Ubuntu 16.04.5 LTS

>atrix products: default
>BLAS: /usr/lib/libblas/libblas.so.3.6.0
>LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

>locale:
> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=ru_RU.UTF-8       
> [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=ru_RU.UTF-8    LC_MESSAGES=en_US.UTF-8   
> [7] LC_PAPER=ru_RU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
>[10] LC_TELEPHONE=C             LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=C       

>attached base packages:
>[1] stats     graphics  grDevices utils     datasets  methods   base     

>loaded via a namespace (and not attached):
>[1] compiler_3.4.4 tools_3.4.4    yaml_2.2.0

我已尝试将 libgfortran 和 gcc-6 更新到最新版本,运行 apt-get update 和 upgrade。在此先感谢您的帮助。

编辑:根据 Norbert 的要求:dpkg -S /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a 的输出

dpkg-query: no path found matching pattern /usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a

尽管文件夹 /usr/lib/gcc/x86_64-linux-gnu/6/ 包含指向 /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a 的链接,但 dpkg -S /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a 的输出

libgfortran-5-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a

编辑2:将 /usr/lib/gcc/x86_64-linux-gnu/6/ 移动到其他位置会导致出现以下错误:

Installing package into ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)

trying URL 'https://cloud.r-project.org/src/contrib/mclust_5.4.2.tar.gz'

Content type 'application/x-gzip' length 2699941 bytes (2.6 MB)

==================================================

downloaded 2.6 MB



* installing *source* package ‘mclust’ ...

** package ‘mclust’ 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 init.c -o init.o

gcc: error trying to exec 'cc1': execvp: No such file or directory

/usr/lib/R/etc/Makeconf:162: recipe for target 'init.o' failed

make: *** [init.o] Error 1

ERROR: compilation failed for package ‘mclust’

* removing ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.5/mclust’

Warning in install.packages :

  installation of package ‘mclust’ had non-zero exit status



The downloaded source packages are in

‘/tmp/RtmpU0X2uP/downloaded_packages’

编辑3:我也尝试将 R 更新到 3.5.2。错误消息仍然相同,这是新的 sessioinfo:

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                   LC_TIME=ru_RU.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=ru_RU.UTF-8        LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=ru_RU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
 [10] LC_TELEPHONE=C             LC_MEASUREMENT=ru_RU.UTF-8  LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] BiocManager_1.30.4 compiler_3.5.2     tools_3.5.2        yaml_2.2.0        

编辑4:安装 igraph 包时我也遇到了非常类似的错误:

/usr/bin/x86_64-linux-gnu-ld: /usr/lib/gcc/x86_64-linux- gnu/6/libgfortran.a(etime.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/6/libgfortran.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'igraph.so' failed
make: *** [igraph.so] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/home/ivan/R/x86_64-pc-linux-gnu-library/3.5/igraph’
Warning in install.packages :
  installation of package ‘igraph’ had non-zero exit status

编辑5:我也尝试过通过 Rscript 使用 sudo 运行 install.packages("mclust",lib="/home/ivan/R/x86_64-pc-linux-gnu-library/3.5"),但结果还是一样的错误。

答案1

因此,如果有人遇到同样的问题 - 我已经通过删除 gcc、r 和 build essentials 包,然后重新安装它们,然后根据以下说明重新安装 R 来修复它适用于 Ubuntu 的 R 3.5.0,@krlmlr 的回答。

相关内容