简体   繁体   English

如何在软件包安装期间解决“libRblas.so:没有这样的文件或目录”?

[英]How to resolve 'libRblas.so: No such file or directory' during package installation?

When I try to install certain packages ( imputeTS ) that need libRblas.so which AFAIK refers to OpenBLAS I get an error that it was not found:当我尝试安装某些需要libRblas.so的软件包( imputeTS )时,AFAIK 指的是 OpenBLAS ,我收到一个找不到的错误:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/jay/R/x86_64-pc-linux-gnu-library/4.2/fracdiff/libs/fracdiff.so':
  libRblas.so: cannot open shared object file: No such file or directory
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted

However, the sessionInfo() indicates, that R actually finds it.但是, sessionInfo()表明,R 实际上找到了它。

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

I learned from this thread that "maybe ... another version of R [was built] and it sits in ... [the] $PATH before the packaged version" , which is likely to be the case;我从这个线程中了解到“也许......另一个版本的 R [已构建],它位于...... [the] $PATH before the packaged version” ,很可能是这种情况; my former R version 4.2.0 was a self-compiled one, and I removed it by downloading the source again and ./configure - make uninstall .我以前的 R 版本4.2.0是自编译的,我通过再次下载源代码和./configure - make uninstall将其删除。 This one is installed via sudo apt install r-base-core , though.不过,这个是通过sudo apt install r-base-core Probably now there is a mess somewhere.可能现在某处有些混乱。 Unfortunately the cited thread was solved differently, and I'm looking now for the respective conclusion.不幸的是,引用的线程以不同的方式解决,我现在正在寻找各自的结论。

Here is some more information:以下是更多信息:

whereis R gives whereis R给出

~$ whereis R
R: /usr/bin/R /usr/lib/R /usr/lib64/R /etc/R /usr/local/lib/R /usr/share/R /usr/share/man/man1/R.1.gz

From the respective files from the error message, using sudo find ~ -name '<file>' , fracdiff.so was found, whereas libRblas.so wasn't.从错误消息中的相应文件中,使用sudo find ~ -name '<file>'找到libRblas.so fracdiff.so找到。

~/R/x86_64-pc-linux-gnu-library/4.2/fracdiff/libs/fracdiff.so

I already tried,我已经试过了,

~$ sudo apt install libopenblas-dev

but obviously it is installed.但显然它已安装。

libopenblas-dev is already the newest version (0.3.20+ds-1).

Following the suggestions of this , libRlapack.so and libRblas.so obviously don't exist on my system, and the other suggestion just gives:按照this的建议, libRlapack.solibRblas.so显然在我的系统上不存在,而另一个建议只是给出:

~$ sudo update-alternatives --config libblas.so
update-alternatives: error: no alternatives for libblas.so

There should never be a "requirement" for libRblas.so . libRblas.so永远不应该有“要求”。 In short, R allows you to build with the BLAS and LAPACK (subset of) sources it shipts, you then get this libRblas.so .简而言之,R 允许您使用它提供的 BLAS 和 LAPACK(子集)源进行构建,然后您将获得这个libRblas.so Or you can use the system BLAS and LAPACK libraries, which the Debian (and hence Ubuntu) package I am responsible for has been doing for probably close to twenty years, and which allows you to switch BLAS installation (Atlas, OpenBLAS, MKL, back in the day also Goto, ...).或者您可以使用系统 BLAS 和 LAPACK 库,我负责的 Debian(以及因此的 Ubuntu)软件包可能已经使用了将近 20 年,并且允许您切换 BLAS 安装(Atlas、OpenBLAS、MKL,返回在当天也转到,...)。

As a demonstration, I just launched a suitable Ubuntu 22.04 Docker container based on r2u as it combines having R pre-made (using my r-base-core package with the external BLAS linkage) as well as the (awesome !!) ability to take all of CRAN as Ubuntu binaries (see r2u for more).作为演示,我刚刚启动了一个合适的基于r2u的 Ubuntu 22.04 Docker 容器,因为它结合了预先制作的 R(使用我的r-base-core包和外部 BLAS 链接)以及(真棒!!)将所有CRAN 作为 Ubuntu 二进制文件(请参阅r2u了解更多信息)。 In short:简而言之:

edd@rob:~$ docker run --rm -ti --security-opt seccomp=unconfined eddelbuettel/r2u:jammy                                                                                                                            
root@818091e49861:/# export PS1="root@r2u_docker:\w# "                                                                                                                                                             
root@r2u_docker:/# echo "192.168.1.114 dirk.eddelbuettel.com" >> /etc/hosts                                                                                                                                        
root@r2u_docker:/# install.r imputeTS              ## one command !!                                                                                                                                                                
Install system packages as root...                                                                                                                                                                                 
Reading package lists... Done                                                                                                                                                                                      
Building dependency tree... Done                                                                                                                                                                                   
Reading state information... Done                                                                                                                                                                                  
Ign https://dirk.eddelbuettel.com/cranapt jammy InRelease                                                                                                                                                         
Hit https://dirk.eddelbuettel.com/cranapt jammy Release                                                                                                                                                           
Hit http://archive.ubuntu.com/ubuntu jammy InRelease                                                                                                                                                              
Hit http://archive.ubuntu.com/ubuntu jammy-updates InRelease                                                                                                                                                      
Hit http://archive.ubuntu.com/ubuntu jammy-backports InRelease                                                                                                                                                    
Hit http://security.ubuntu.com/ubuntu jammy-security InRelease                                                                                                                                                     
Get:1 https://ppa.launchpadcontent.net/marutter/rrutter4.0/ubuntu jammy InRelease [17.5 kB]                                                                                                                        
Fetched 17.5 kB in 0s (0 B/s)                                                                                                                                                                                     
Reading package lists... Done                                                                                                                                                                                      
Building dependency tree... Done                                                                                                                                                                                   
Reading state information... Done                                                                                                                                                                                  
Get:1 https://dirk.eddelbuettel.com/cranapt jammy/main amd64 r-cran-bitops amd64 1.0-7-1.ca2204.1 [25.5 kB]                                                                                                       
Get:2 https://dirk.eddelbuettel.com/cranapt jammy/main amd64 r-cran-glue amd64 1.6.2-1.ca2204.1 [143 kB]                                                                                                           
[... cutting here to satisfy SO quote limit ...]
Setting up r-cran-forecast (8.16-1.ca2204.1) ...
Setting up r-cran-imputets (3.2-1.ca2204.1) ...
root@r2u_docker:/# 

after which we can indeed launch R and load it just fine:之后我们确实可以启动 R 并加载它就好了:

root@r2u_docker:/# R

R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(imputeTS)
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
> 

It uses external BLAS/LAPACK "by design":它“按设计”使用外部 BLAS/LAPACK:

root@r2u_docker:/# dpkg -l | grep -i "blas\|lapack" | cut -c-90
ii  libblas-dev:amd64            3.10.0-2ubuntu1                         amd64        Basi
ii  libblas3:amd64               3.10.0-2ubuntu1                         amd64        Basi
ii  liblapack-dev:amd64          3.10.0-2ubuntu1                         amd64        Libr
ii  liblapack3:amd64             3.10.0-2ubuntu1                         amd64        Libr
root@r2u_docker:/# 

So I think this may be self-imposed by a combination of you having maybe compiled R locally plus the imputeTS not dealing well with that (it should, it may be a bug).所以我认为这可能是你自己在本地编译 R加上imputeTS不能很好地处理它(它应该,它可能是一个错误)的组合。 But I hope this also shows that this can be so much easier too.但我希望这也表明这也可以容易得多。

If you have more detailed follow-up questions please come to the r-sig-debian list which is friendly, no-sensense and low-volume.如果您有更详细的后续问题,请来到友好、无意义和低容量的r-sig-debian列表。

PS For completness, the container's sessionInfo() in a fresh session: PS 为了完整起见,容器的sessionInfo()在新会话中:

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.1 bspm_0.3.9    
> 

PPS A 'live' demo in one animated gif is in this tweet (tweeted as one cannot attach gifs over 2mb here). PPS 一条动画 gif 中的“实时”演示在此推文中(推文是因为无法在此处附加超过 2mb 的 gif)。

Some comments have put me on the right track and helped me to solve the problem—I will briefly summarize.一些评论让我走上了正轨,帮助我解决了问题——我将简要总结一下。

Since a dependencies issue was suspected, I installed the package from which the error message originated ( fracdiff in this case) and tried again to install the target package.由于怀疑存在依赖关系问题,我安装了产生错误消息的包(在本例中为fracdiff ),并再次尝试安装目标包。 The error reoccurred, but came from a different package indicating cascading problems.错误再次发生,但来自不同的包,表明级联问题。 Weirdly enough, I definitely knew the package was installed, so I felt my initial suspicion confirmed, that I might have made a mess with the libs folders when updating R as described in the OP.奇怪的是,我绝对知道该软件包已安装,所以我觉得我最初的怀疑得到了证实,我可能在更新 R 时弄乱了libs文件夹,如 OP 中所述。

Since I could assume that this would happen again and again, the conclusion was to uninstall R completely, and this time the packages as well, and then reinstall everything.由于我可以假设这种情况会一次又一次地发生,因此结论是完全卸载 R,这次也卸载软件包,然后重新安装所有内容。 Now I could install the target package among others without any problems.现在我可以毫无问题地安装目标包。

Fortunately, this is quite easy on Linux.幸运的是,这在 Linux 上非常容易。 Also all packages can be reinstalled relatively unattended.此外,所有软件包都可以在相对无人值守的情况下重新安装。 The how-to's are spread out over several threads and sites, I'll put the strings together, adding the references.操作方法分布在多个线程和站点上,我将把字符串放在一起,添加参考。

Here is what I did in R and in Bash (you will need su/sudo ):这是我在 R 和 Bash 中所做的(你需要su/sudo ):

  1. Store packages (in R) 1存储包(在 R 中) 1
tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
saveRDS(installedpkgs, 'installed_old.rds')
  1. Remove R completely 2完全删除 R 2
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | sudo xargs apt-get remove --purge -y
  1. Remove all R packages 3删除所有 R 包3

The locations might differ from yours.这些位置可能与您的不同。

R -e '.libPaths()'
rm -rf /home/jay/R/x86_64-pc-linux-gnu-library/4.2 /usr/local/lib/R/site-library /usr/lib/R/site-library /usr/lib/R/library
  1. Install R (here with apt ) 4安装 R(这里用apt4
apt install r-base-core
  1. Restore R packages 5恢复 R 包5

This runs for a while.这会运行一段时间。 Note that only packages that can be found in repositories are installed.请注意,仅安装可以在存储库中找到的包。

installedpkgs <- readRDS("installed_old.rds")
tmp <- installed.packages()
installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
missing <- setdiff(installedpkgs, installedpkgs.new)
install.packages(missing)
update.packages(ask=FALSE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM