当前位置:   article > 正文

linux安装包报错-monocle包_error in download.file(url, destfile, method, mode

error in download.file(url, destfile, method, mode = "wb", ...) : download f

安装代码

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("monocle")
  • 1
  • 2
  • 3
  • 4

安装monocle包报错1

Error in download.file(url, destfile, method, mode = "wb", ...) :
  download from 'https://bioconductor.org/packages/3.15/bioc/src/contrib/monocle_2.24.1.tar.gz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 6533867 != reported length 9450203
2: In download.file(url, destfile, method, mode = "wb", ...) :
  URL 'https://bioconductor.org/packages/3.15/bioc/src/contrib/monocle_2.24.1.tar.gz': Timeout of 300 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘monocle’ failed
ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying
Try removing ‘/usr/local/lib/R/site-library/00LOCK-RBGL’
ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying
Try removing ‘/usr/local/lib/R/site-library/00LOCK-DDRTree’

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

报错里面提到

Error in download.file(url, destfile, method, mode = "wb", ...) :
  download from 'https://bioconductor.org/packages/3.15/bioc/src/contrib/monocle_2.24.1.tar.gz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 6533867 != reported length 9450203
2: In download.file(url, destfile, method, mode = "wb", ...) :
  URL 'https://bioconductor.org/packages/3.15/bioc/src/contrib/monocle_2.24.1.tar.gz': Timeout of 300 seconds was reached
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

可能是由于网络问题

ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying
Try removing ‘/usr/local/lib/R/site-library/00LOCK-RBGL’
ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying
Try removing ‘/usr/local/lib/R/site-library/00LOCK-DDRTree’
  • 1
  • 2
  • 3
  • 4

原因:网络不好,以前安装的未成功,残留文件
解决:删除R目录下 /usr/local/lib/R/site-library中的00LOCK-RBGL文件夹
以及/usr/local/lib/R/site-library中的00LOCK-DDRTree文价夹
或者,安装时候用

install.packages("stringi", dependencies=TRUE, INSTALL_opts = c('--no-lock'))
  • 1

安装monocle包报错2

Error: package or namespace load failed for ‘leidenbase’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/00LOCK-leidenbase/00new/leidenbase/libs/leidenbase.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/leidenbase’
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

原因:网络不好,以前安装的未成功,残留文件
解决:删除R目录下/usr/local/lib/R/site-library/leidenbase

重新尝试以后再次报错

Error: package or namespace load failed for ‘leidenbase’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/00LOCK-leidenbase/00new/leidenbase/libs/leidenbase.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/leidenbase’

Warning messages:
1: In install.packages(...) :
  installation of package ‘leidenbase’ had non-zero exit status
2: In install.packages(...) :
  installation of package ‘monocle’ had non-zero exit status

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

其实错误的根本是在R中安装包的时候调用了系统安装的非R的动态库,在本地lib路径( 不是 R 软件包) 中有 libiconv.so,包含在 LD_LIBRARY_PATH 中,在 R 会话中验证也可以发现

Sys.getenv("LD_LIBRARY_PATH")
  • 1
[1] "/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/lib/server"
  • 1

具有该目录。但是R 库加载程序时无法找到这里共享对象,所以这个错误就是R包的非R依赖项的问题。

1.linux系统中 -没有效果

apt-get install libglpk40
  • 1

2.清洗器解决办法

使用withr::with_makevars,这个方法允许临时控制Makevars内容,使用这个方式,可以直接从repo安装R包:

withr::with_makevars(c(PKG_LIBS = "-libgfortran"), install.packages("leidenbase"), assignment = "+=")

## or

with_makevars(c(PKG_CFLAGS = "-std=c11"), install.packages("plyr", repos = NULL, type = "source"), assignment = "+=")
  • 1
  • 2
  • 3
  • 4
  • 5

3.观察到有一点报错的情况 -有用

ImportError: libgfortran.so.4: cannot open shared object file: No such file or directory
  • 1

解决方法

find ~ -name libgfortran.so.4.0.0
  • 1

显示

/root/anaconda3/lib/libgfortran.so.4.0.0
/root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4.0.0
  • 1
  • 2

查找

find ~ -name libgfortran.so.4
  • 1

显示

/root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4
  • 1

运行如下命令

ln -s /root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4  /usr/lib/x86_64-linux-gnu
ln -s /root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4 /usr/lib/R/lib
ln -s /root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4 /usr/lib/jvm/default-java/lib/server
  • 1
  • 2
  • 3

Rstudio又报错

Error: package or namespace load failed for ‘monocle’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/leidenbase/libs/leidenbase.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
  • 1
  • 2
  • 3

解决
在网页版Rstudio运行

install.packages("leidenbase",force = TRUE)
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/333504
推荐阅读
相关标签
  

闽ICP备14008679号