if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("monocle")
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’
报错里面提到
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
可能是由于网络问题
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’
原因:网络不好,以前安装的未成功,残留文件
解决:删除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'))
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’
原因:网络不好,以前安装的未成功,残留文件
解决:删除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
其实错误的根本是在R中安装包的时候调用了系统安装的非R的动态库,在本地lib路径( 不是 R 软件包) 中有 libiconv.so,包含在 LD_LIBRARY_PATH 中,在 R 会话中验证也可以发现
Sys.getenv("LD_LIBRARY_PATH")
[1] "/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/lib/server"
具有该目录。但是R 库加载程序时无法找到这里共享对象,所以这个错误就是R包的非R依赖项的问题。
apt-get install libglpk40
使用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 = "+=")
ImportError: libgfortran.so.4: cannot open shared object file: No such file or directory
解决方法
find ~ -name libgfortran.so.4.0.0
显示
/root/anaconda3/lib/libgfortran.so.4.0.0
/root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4.0.0
查找
find ~ -name libgfortran.so.4
显示
/root/anaconda3/pkgs/libgfortran4-7.5.0-ha8ba4b0_17/lib/libgfortran.so.4
运行如下命令
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
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
解决
在网页版Rstudio运行
install.packages("leidenbase",force = TRUE)