簡體   English   中英

rjava 和 java 問題與 r on mac os mojave 問題

[英]rjava and java issue with r on mac os mojave issue

我最近更新到最新的 R 版本和 Mojave。 我不能再讓 Rjava 工作了。 我嘗試閱讀關於此的許多主題,但我無法弄清楚我做錯了什么......

Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
  Reason: image not found
Error: package ‘rJava’ could not be loaded
輸入這個到終端...
 sudo R CMD javareconf



Java interpreter : /usr/bin/java
Java version     : 10.0.1
Java home path   : /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
System Java on macOS

trying to compile and link a JNI program 
detected JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
detected JNI linker flags : -framework JavaVM
x86_64-apple-darwin13.4.0-clang -I/anaconda3/lib/R/include -DNDEBUG -I/System/Library/Frameworks/JavaVM.framework/Headers  -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/anaconda3/include   -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/anaconda3/include -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix  -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: 'jni.h' file not found
#include <jni.h>
         ^~~~~~~
1 error generated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program, ignoring this though as you may not want to compile anything here
.. this is an Anaconda Distribution and conda-forge customization whereby env activation causes us
.. to call R CMD javareconf in order to dynamically detect a JDK that may be in that env. The fact
.. that we prohibit setting LD_LIBRARY_PATH is also somewhat responsible for us needing to do this
.. because ${R_HOME}/etc/ldpaths is the normal way that R dynamically finds shared libraries. This
.. is what would, in upstream R, set LD_LIBRARY_PATH. AD cannot set this as it causes all sorts of
.. issues with DT_RUNPATH / DT_RPATH on various distributions.


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Java library path: 
JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
JNI linker flags : -framework JavaVM
Updating Java configuration in /anaconda3/lib/R
Done.

當我跑

 sudo R CMD javareconf Java interpreter : /usr/bin/java Java version : 10.0.1 Java home path : /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home Java compiler : /usr/bin/javac Java headers gen.: /usr/bin/javah Java archive tool: /usr/bin/jar System Java on macOS trying to compile and link a JNI program detected JNI cpp flags : -I/System/Library/Frameworks/JavaVM.framework/Headers detected JNI linker flags : -framework JavaVM x86_64-apple-darwin13.4.0-clang -I/anaconda3/lib/R/include -DNDEBUG -I/System/Library/Frameworks/JavaVM.framework/Headers -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/anaconda3/include -fPIC -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/anaconda3/include -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix -c conftest.c -o conftest.o conftest.c:1:10: fatal error: 'jni.h' file not found #include <jni.h> ^~~~~~~ 1 error generated. make: *** [conftest.o] Error 1 Unable to compile a JNI program, ignoring this though as you may not want to compile anything here .. this is an Anaconda Distribution and conda-forge customization whereby env activation causes us .. to call R CMD javareconf in order to dynamically detect a JDK that may be in that env. The fact .. that we prohibit setting LD_LIBRARY_PATH is also somewhat responsible for us needing to do this .. because ${R_HOME}/etc/ldpaths is the normal way that R dynamically finds shared libraries. This .. is what would, in upstream R, set LD_LIBRARY_PATH. AD cannot set this as it causes all sorts of .. issues with DT_RUNPATH / DT_RPATH on various distributions. JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home Java library path: JNI cpp flags : -I/System/Library/Frameworks/JavaVM.framework/Headers JNI linker flags : -framework JavaVM Updating Java configuration in /anaconda3/lib/R Done.

有人可以告訴我我必須做什么嗎? 我確定這已經重復了很多次並且很明顯,但我無法弄清楚或正確執行。

在 Mac OS 版本、Java 版本和 rJava 版本之間切換可能會很困難。

在此處查看您可能需要采取的非常全面的步驟列表:

http://www.owsiak.org/r-3-4-rjava-macos-and-even-more-mess/

您可能需要從源代碼重新編譯 rJava 才能使其在您的環境中工作。

https://github.com/rstudio/rstudio/issues/2750轉貼最快最有效

sudo ln -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM