1

我已经使用 R 一段时间了,安装软件包时一切正常。最近,我在Ubuntu 16.04from 3.4.4to上升级了 R 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 的包也是同样的结果!

还有两个评论,第一个是(as ‘lib’ is unspecified)升级 R 后才开始出现这个语句。第二个,我不确定是否相关,是我的 linux 上没有空间!

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

4

1 回答 1

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'</li>
  • 删除“/home/.../R/x86_64-pc-linux-gnu-library/4.0/gridtext”错误:依赖项“gridtext”不适用于包“ggtext”</li>
  • 删除“/home/.../R/x86_64-pc-linux-gnu-library/4.0/ggtext”错误:依赖项“ggtext”不适用于包“imputeTS”</li>
  • 删除 '/home/.../R/x86_64-pc-linux-gnu-library/4.0/imputeTS'</li>

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
于 2020-10-02T03:34:30.850 回答