I am using macOS Sierra and R version 3.4.0.
I installed the package "rJava" using RStudio:
install.packages("rJava")
Warning in install.packages :
cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/rJava_0.9-8.tgz'
Content type 'application/x-gzip' length 627959 bytes (613 KB)
==================================================
downloaded 613 KB
The downloaded binary packages are in
/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T//RtmpTdEVbA/downloaded_packages
Then when I try to run rJava I get:
> require(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.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
R, rJava and Java are little bit messy in macOS. In general, you have to make sure to properly configure all the elements. There is a clash between Oracle's and Apple's version.
Take a look here for very detailed instructions: R, Java, rJava and macOS adventures
I don't post the content here - it's quite long.
Related
I have installed an R package in my Macbook (Big Sur), but I am getting error when I use library(packagename). I have uninstalled the R and then reinstalled it, but it is still giving me same error. I am wondering if there are any PATH settings I need to do.
> BiocManager::install("DNAcopy", force = TRUE)
Bioconductor version 3.16 (BiocManager 1.30.19), R 4.2.2 (2022-10-31)
Installing package(s) 'DNAcopy'
trying URL 'https://bioconductor.org/packages/3.16/bioc/bin/macosx/contrib/4.2/DNAcopy_1.72.1.tgz'
Content type 'application/x-gzip' length 510684 bytes (498 KB)
==================================================
downloaded 498 KB
The downloaded binary packages are in
/var/folders/h1/01m4_1gn65g63hvbv15tq7000000gr/T//RtmpEOBgrr/downloaded_packages
> library(DNAcopy)
Error: package or namespace load failed for ‘DNAcopy’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/DNAcopy/libs/DNAcopy.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/DNAcopy/libs/DNAcopy.so, 6): Symbol not found: __gfortran_os_error_at
Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/library/DNAcopy/libs/DNAcopy.so
Expected in: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libgfortran.5.dylib
in /Library/Frameworks/R.framework/Versions/4.2/Resources/library/DNAcopy/libs/DNAcopy.so
I would really appreciate any help.
I have tried re-insattling the packages as well as R.
I'm working on a project on R studio and I got a error message while installing qdap on my mac and running the library function.
And this is what I got.
install.packages('qdap')
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/qdap_2.3.0.tgz'
Content type 'application/x-gzip' length 4164745 bytes (4.0 MB)
==================================================
downloaded 4.0 MB
The downloaded binary packages are in
/var/folders/0v/c58lzwxd513g64xxc0gd85rm0000gn/T//RtmphbntNA/downloaded_packages
> library('qdap')
Error: package or namespace load failed for ‘qdap’:
.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-9.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
I found that the problem is that R is not able to locate Java_home correctly.
Steps to follow:
Download and install Java JDK if you haven't already done so.
In Terminal, find java location by typing which java
Set JAVA_HOME in R as Sys.setenv("JAVA_HOME" = 'your java location such as /usr/bin/java').
Try reinstalling the packages openNLP, rJava, and qdap.
I tried to find solutions from previous posts, but they do not solve my problem.
I am using macOS High Sierra and have Java installed. Below is the error reported by Rstudio. Also, rJava, Mac, and R are really messy with each other. I found this post but still does not work.
https://github.com/MTFA/CohortEx/wiki/Run-rJava-with-RStudio-under-OSX-10.10,-10.11-(El-Capitan)-or-10.12-(Sierra)
///////////////////
library(RWeka)
Error: package or namespace load failed for ‘RWeka’:
.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.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning message:
package ‘RWeka’ was built under R version 3.4.4
I met the same question and I found this is helpful.
Cannot load R xlsx package on Mac OS 10.11
1.In terminal enter the following to relink Java correctly:
sudo R CMD javareconf
2.Back in R (or RStudio) install the rJava package from source:
install.packages("rJava",type='source')
Then
library(rJava)
and
library(RWeka)
should work.
I am running MacOS 10.13 (High Sierra) and recently updated to R version 3.4.3 and R studio version 1.1.419. For some reason the rJava package is not working...tried several fixes from here on stackoverflow and nothing works. Also, the digest package will not load so I can no longer use ggplot2. Any suggestions?
Error for Java:
> library("rJava", lib.loc="/Library/Frameworks/R.framework/Versions/3.4/Resources/library")
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.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error for digest package:
> library("rJava", lib.loc="/Library/Frameworks/R.framework/Versions/3.4/Resources/library")
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.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
New Mac OSX releases have a documented problem of messing up the Java path in R/RStudio (see here). It looks as though that this is what you're encountering here.
If you check out the question I've linked above, hopefully you can find a solution that works to reset your path; both of the commands below worked for me.
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
or
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
I don't know about the problem with rJava, but digest was just updated so if you try to install the binary it may not compiled and built yet. If that ever happens (it's somewhat of a race condition/lag), you can try to reinstall form source:
install.packages("digest", type = "source")
After updating to the latest version of Rstudio (R version 3.4.1 (2017-06-30) -- "Single Candle") I cannot seem to get the XLConnect Package to load. This is the error message I get:
> library('XLConnect')
Loading required package: XLConnectJars
Error: package or namespace load failed for ‘XLConnectJars’:.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.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package ‘XLConnectJars’ could not be loaded
R also throws a similar error message when I try to load the rJava package as well. I have tried uninstalling both Java and R and have scoured SO for answers, but nothing seems to work.
I am running macOS Sierra (10.12.6)
Would anyone be willing to offer any help?
The error suggests that there is an issue loading rJava. Try updating the Java configuration variables via R CMD javareconf or sudo R CMD javareconf.