无法安装ggp​​lot2:“library.dynam(lib,package,package.lib)中的错误:找不到共享对象'stringi.so'”

时间:2015-08-06 21:42:00

标签: r ubuntu ggplot2

上周我从Ubuntu 14.04升级到14.10。自从更新以来我第一次尝试在RStudio中使用ggplot,我的ggplot包中出现了依赖性错误,并且不再注册为已安装(之前工作正常)。当我尝试重新安装ggp​​lot2时:

install.packages("ggplot2",dep=TRUE)

尝试安装依赖项时安装失败。这是输出尾部的样子:

* installing *source* package ‘stringr’ ...
** package ‘stringr’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error in library.dynam(lib, package, package.lib) : 
  shared object ‘stringi.so’ not found
ERROR: lazy loading failed for package ‘stringr’
* removing ‘/home/james/R/x86_64-pc-linux-gnu-library/3.1/stringr’
Warning in install.packages :
  installation of package ‘stringr’ had non-zero exit status
ERROR: dependency ‘stringr’ is not available for package ‘reshape2’
* removing ‘/home/james/R/x86_64-pc-linux-gnu-library/3.1/reshape2’
Warning in install.packages :
  installation of package ‘reshape2’ had non-zero exit status
ERROR: dependency ‘reshape2’ is not available for package ‘ggplot2’
* removing ‘/home/james/R/x86_64-pc-linux-gnu-library/3.1/ggplot2’
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

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

我有一种感觉这就是我应该看的线(下面),但我不确定如何解释这个错误,有人对我有什么建议吗?我真的不知道从哪里开始,因为我发现任何其他人都遇到了和我一样的错误。

Error in library.dynam(lib, package, package.lib) : 
  shared object ‘stringi.so’ not found

不确定我做的Ubuntu升级是否与此有关......但我想我会提到它以防万一。

3 个答案:

答案 0 :(得分:14)

根据@Nick Kennedey的评论,我尝试像这样安装stringi

> install.packages("stringi",dep=TRUE)

导致我之前没见过的错误:

2015-08-07 10:26:35 (256 KB/s) - ‘/tmp/RtmpQI4Uau/downloaded_packages/stringi_0.5-5.tar.gz’ saved [3639183/3639183]

ERROR: failed to lock directory ‘/home/james/R/x86_64-pc-linux-gnu-library/3.1’ for modifying
Try removing ‘/home/james/R/x86_64-pc-linux-gnu-library/3.1/00LOCK-stringi’
Warning in install.packages :
  installation of package ‘stringi’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpQI4Uau/downloaded_packages’
> install.packages("stringi",dep=TRUE)

所以我按照错误中的建议删除了LOCK文件夹。

在终端:rm -r /home/james/R/x86_64-pc-linux-gnu-library/3.1/00LOCK-stringi’

然后再次尝试安装stringi包,它有效!这就是问题......现在我刚刚完成安装而没有任何问题。

我仍然有点困惑......至于这个错误是如何产生的。有关导致这种情况的任何想法,以后我可以避免它吗?是否有可能是我最近升级到14.10的症状?

答案 1 :(得分:1)

在安装install.packages("knitr")时出现相同的错误

  

dyn.load(file,DLLpath = DLLpath,...)中的错误:     无法加载共享对象'/usr/local/lib/R/site-library/stringi/libs/stringi.so'

我通过以下操作解决了该问题:

在Ubuntu 16.04及更高版本中

sudo apt install r-cran-stringi

在早期版本中(具有apt-get)

sudo apt-get install r-cran-stringi

答案 2 :(得分:0)

在我的情况下,我通过从linux终端安装stringi和ggplot2解决了这个问题。这个问题与RStudio存在某种关系。