为什么无法安装某些R软件包

时间:2020-09-22 10:24:27

标签: r linux package ubuntu-16.04 imputets

我使用R已有一段时间了,安装软件包时一切正常。最近,我将Ubuntu 16.04上的R从3.4.4升级到4.0.2,然后尝试将软件包imputeTS安装为

> install.packages("imputeTS")
Installing package into ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘png’, ‘gridtext’, ‘ggtext’

trying URL 'https://cloud.r-project.org/src/contrib/png_0.1-7.tar.gz'
Content type 'application/x-gzip' length 24990 bytes (24 KB)
==================================================
downloaded 24 KB

trying URL 'https://cloud.r-project.org/src/contrib/gridtext_0.1.1.tar.gz'
Content type 'application/x-gzip' length 441462 bytes (431 KB)
==================================================
downloaded 431 KB

trying URL 'https://cloud.r-project.org/src/contrib/ggtext_0.1.0.tar.gz'
Content type 'application/x-gzip' length 1849875 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/imputeTS_3.1.tar.gz'
Content type 'application/x-gzip' length 3015320 bytes (2.9 MB)
==================================================
downloaded 2.9 MB

* installing *source* package ‘png’ ...
** package ‘png’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG      `libpng-config --cflags` -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c read.c -o read.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG      `libpng-config --cflags` -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c write.c -o write.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o png.so read.o write.o -L/home/.../anaconda/lib -lpng16 -lm -lz -lm -L/usr/lib/R/lib -lR
installing to /home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘png’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs/png.so':
  libpng16.so.16: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/png’
ERROR: dependency ‘png’ is not available for package ‘gridtext’
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/gridtext’
ERROR: dependency ‘gridtext’ is not available for package ‘ggtext’
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/ggtext’
ERROR: dependency ‘ggtext’ is not available for package ‘imputeTS’
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/imputeTS’

The downloaded source packages are in
    ‘/tmp/RtmpZubgYt/downloaded_packages’
Warning messages:
1: In install.packages("imputeTS") :
  installation of package ‘png’ had non-zero exit status
2: In install.packages("imputeTS") :
  installation of package ‘gridtext’ had non-zero exit status
3: In install.packages("imputeTS") :
  installation of package ‘ggtext’ had non-zero exit status
4: In install.packages("imputeTS") :
  installation of package ‘imputeTS’ had non-zero exit status

然后

> library(imputeTS)
Error in library(imputeTS) : there is no package called ‘imputeTS’

我尝试安装与install.packages("imputeTS", dependencies = TRUE)相同的软件包,但这给了我相同的结果installation of package ‘imputeTS’ had non-zero exit status

接下来,我尝试安装软件包Hmiscmice。对于第一个成功安装mice的软件包,结果相同!

还有另外两条评论,第一条是该语句(as ‘lib’ is unspecified)在升级R之后开始出现。第二条,我不确定是否相关,是我的Linux上没有空间了!

那我怎样才能成功安装所需的软件包?

1 个答案:

答案 0 :(得分:0)

总结一下,人们可以更好地找到评论中给出的正确答案并理解错误消息

这与imputeTS软件包无关。

这可以在错误消息的这一部分中看到

错误:dyn.load(文件,DLLpath = DLLpath,...)中“ png”的包或名称空间加载失败: 无法加载共享对象'/home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs/png.so': libpng16.so.16:无法打开共享库文件:没有这样的文件或目录

尝试安装png软件包时实际上发生了错误。

这与imputeTS软件包有什么关系?

您可以在这里看到它:

错误:加载失败

  • 删除“ /home/.../R/x86_64-pc-linux-gnu-library/4.0/png” 错误:依赖项“ png”不适用于程序包“ gridtext”
  • 删除“ /home/.../R/x86_64-pc-linux-gnu-library/4.0/gridtext” 错误:依赖性“ gridtext”不适用于软件包“ ggtext”
  • 删除“ /home/.../R/x86_64-pc-linux-gnu-library/4.0/ggtext” 错误:依赖性“ ggtext”不适用于软件包“ imputeTS”
  • 删除“ / home /.../ R / x86_64-pc-linux-gnu-library / 4.0 / imputeTS”

R程序包彼此建立并导入其他程序包的功能。在这种情况下,imputeTS会导入ggtext,后者会导入gridtext,而后者会导入png。

因此有一系列依赖性,如果png的安装失败,则会影响所有其他软件包。

幸运的是,错误消息的这一部分也给出了提示,可能是什么错误:

无法加载共享对象'/home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs/png.so': libpng16.so.16:无法打开共享库文件:没有这样的文件或目录

缺少png包本身所依赖的库。没有此库,png的安装将失败并导致所有上述问题。

因此只需安装如下库:

sudo apt-get install libpng16-16