问题
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
library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details: call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Lauriane/Documents/R/win-library/3.3/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
Error: package or namespace load failed for ‘rJava’
Please help,
Thanks
回答1:
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.
回答2:
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.
回答3:
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.
回答4:
What worked for me is explained here. Essentially, do sudo R CMD javareconf
in the terminal and reboot.
回答5:
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!
来源:https://stackoverflow.com/questions/42258473/error-package-or-namespace-load-failed-for-rjava