![libjvm.so:无法打开共享对象文件:没有此文件或目录](https://linux22.com/image/1124330/libjvm.so%EF%BC%9A%E6%97%A0%E6%B3%95%E6%89%93%E5%BC%80%E5%85%B1%E4%BA%AB%E5%AF%B9%E8%B1%A1%E6%96%87%E4%BB%B6%EF%BC%9A%E6%B2%A1%E6%9C%89%E6%AD%A4%E6%96%87%E4%BB%B6%E6%88%96%E7%9B%AE%E5%BD%95.png)
尝试在我的 14.10 ubuntu 上使用此代码在 R 上安装 rJava 包
if (!require(rJava)) install.packages('rJava')
出现了一些与 java 相关的错误,包括 jni 问题,重新安装 jdk 后,尝试再次运行相同的代码,出现了该错误
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/local/lib/R/site-library/rJava/libs/rJava.so':
libjvm.so: 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/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpfFjrp0/downloaded_packages’
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘rJava’
寻找解决方案,发现几乎每个人都建议(对于 x64)执行这些命令
export LD_LIBRARY_PATH=/usr/lib/jvm/java-8-oracle/lib/amd64:/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
sudo R CMD javareconf
但那没用,我还能做什么?我会提供任何需要的详细信息,在整个机器上搜索 libjvm.so 会导致此结果
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/jdk1.8.25/jre/lib/amd64/server/libjvm.so
/usr/local/java/jre1.7.0_75/lib/amd64/server/libjvm.so
答案1
执行以下操作应该可以解决您的问题:
$ export LD_LIBRARY_PATH=/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
$ sudo R CMD javareconf
答案2
有时你需要这个R CMD javareconf -e
答案3
脚步:
找到您的 R 位置。它将存储在文件
rsession-ld-library-path
中rserver.conf
。或者只需执行which R
。位置通常是/usr/lib64/R/lib
或/usr/lib64/microsoft-r/3.3/lib64/R/lib
查找
libjvm.so
文件,该文件通常位于usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server
路径中,具体取决于您使用的 jre。检查echo $JAVA_HOME
。使用创建符号链接
ln -s
sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so /usr/lib64/microsoft-r/3.3/lib64/R/lib/libjvm.so
重启 R 服务器