Error: package or namespace load failed for ‘rJava’

后端 未结 5 1194
一生所求
一生所求 2020-12-16 16:48

So I have tried the previously proposed answer to my question. but I am still having the same error message: I am trying to load the rJava library in R

相关标签:
5条回答
  • 2020-12-16 17:20

    I had the same problem and, as suggested in previous comments, I manually installed the 64-bit version, selecting it here. I only had to restart R. It worked perfectly.

    0 讨论(0)
  • 2020-12-16 17:26

    For me the problem was caused because a 32-bit Java version was installed on the system, but I was running 64-bit version of R. Installing the 64-bit Java version solved the problem with rJava namespace environment. Because I am running a 32-bit browser I had to manually download the 64-bit Java version.

    0 讨论(0)
  • 2020-12-16 17:45

    What worked for me is explained here. Essentially, do sudo R CMD javareconf in the terminal and reboot.

    0 讨论(0)
  • 2020-12-16 17:47

    I'll just add one more possible solution, since I tried all of the suggestions listed above (reinstalling Java x64, installing both JDK & JRE, setting JAVA_HOME, sudo R CMD javareconf or even sudo R CMD javareconf -n seen elsewhere, and more) but none of them worked and I kept getting the following error:

    > library(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.6/Resources/library/rJava/libs/rJava.so':
      dlopen(/Library/Frameworks/R.framework/Versions/3.6/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.6/Resources/library/rJava/libs/rJava.so
      Reason: image not found
    

    There were 2 possible solutions that helped me get through this error:

    • Go to the location of your Java installation (in my Mac OS it was /Library/Java/JavaVirtualMachines/) where you'll find a folder titled something like "jdk-13.0.1.jdk" (depending on your JDK version). Changing its name to "jdk-11.0.1.jdk" (or whatever is mentioned in your error) should solve your problem.

    But maybe even better is to do the following instead:

    • Go to the file referenced in the error: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, open it in a text editor (such as TextEdit) and change "jdk-11.0.1.jdk" to "jdk-13.0.1.jdk" (or whatever is the folder referenced in your error and what is actually in your Java folder, respectively).

    Either way worked for me but the latter looks a bit cleaner to me. Hope this helps someone!

    0 讨论(0)
  • 2020-12-16 17:47

    I had the same problem.

    From what I've understood this was due to two reasons: a) R being 64-bits and Java being on 32-bits, b) R being installed in D:\Documents and Java being installed in C:\Programmes.

    I've solved the issue by:

    • Disinstalling all previous versions of Java
    • Disinstalling both R and RStudio
    • Installing both R, Rstudio and Java in 64 bits in a new folder called D:\Programmes
    • For Java I have installed both the JDK and JRE in the same folder
    • Setting JAVA_HOME as an environment variable making sure that the environment variable was pointing to bin.
    0 讨论(0)
提交回复
热议问题