TclTk library issue while install Rcmdr package on MacBookPro [duplicate] - r

This question already has answers here:
Error ".onLoad failed in loadNamespace() for 'tcltk'"
(7 answers)
Closed 7 years ago.
I get the following ERROR while trying to load Rcmdr for R on my MacBook Pro:
> library("Rcmdr")
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /usr/local/lib/libtcl8.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so
Reason: image not found
Error: package or namespace load failed for ‘Rcmdr’
I have other problem on this machine related to the TclTk libraries, but I didn't get any help when I posted about troubles installing graphviz.
If someone could help me fix the TclTk library issue I would really appreciate it.
Thanks in advance.

Thank your #donal-fellows !
The solutions was to put symlinks to the libs where R expected them:
brew remove tcl-tk
brew -v install tcl-tk --with-tk
ln -s /usr/local/Cellar/tcl-tk/8.6.0/lib/libtcl8.6.dylib /usr/local/lib/libtcl8.6.dylib
ln -s /usr/local/Cellar/tcl-tk/8.6.0/lib/libtk8.6.dylib /usr/local/lib/libtk8.6.dylib
let us now hope that this fixes my graphviz issue!

Related

About "xlsx" package in R [duplicate]

This question already has answers here:
Problems when trying to load a package in R due to rJava
(10 answers)
Error loading xlsx library in R [duplicate]
(1 answer)
Error: package ‘rJava’ could not be loaded when installing xlsx
(1 answer)
Closed 2 years ago.
I installed package xlsx in R studio on Mac. It is the first time to install R studio on this computer. But I got an error when tried to install it:
> library("xlsx")
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘xlsx’:
.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
In addition: Warning message:
In system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
I am not sure what wrong I am doing. Thank you for the help!

rJava installation fails on macOS 10.14

After upgrading to MacOS Mojave (10.14.1), I'm no longer able to install rJava for R version 3.5.1 with Java version "1.8.0_102" installed.
I tried the previous solution for MacOS 10.11 but it still did not work, giving this error:
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-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
Posting the solution I found in case it helps others -- I don't quite understand why this work or if it's the right way so looking for better alternatives!
This issue lead to this Apple forum where it's stated
For legacy software that looks for the macOS headers in the base system under /usr/include, please install the package file located at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg
To do this, open terminal and run these commands
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg
then follow prompts to install the package.
After this, in the terminal, configure rJava and install as in the previous answer
sudo R CMD javareconf
R -e "install.packages('rJava')"
and it should install without problem.
After installing JDK 11.04 LTS I rain into the same error in R Studio on Mojave
R was expecting Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk
Despite running sudo R CMD javareconf the error still persisted
Therefore I browsed to /Library/Java/JavaVirtualMachines/ in finder and renamed the folder "jdk-11.0.4.jdk" to "jdk-11.0.1.jdk"
Restarted R and both library(rJava) and library(xlsx) now work.
Hope this helps someone
I ran into the exact problem. I solved it by:
Install the latest version of Java (dmg file)
Install rJava in Studio: install.packages("rJava")
In the terminal: sudo mv jdk-12.0.1.jdk jdk-11.0.1.jdk
Otherwise the following error will appear in Rstudio:
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
In Rstudio: library(rJava)
rJava should have been loaded without issues.
I ran into same issue, when i was trying to install "rJava" in my macOs (Mojave version).
Below steps i executed to resolve issue.
R version : 3.6.1
issue : configure: error: one or more Java tools are missing.
*** JDK is incomplete! Please make sure you have a complete JDK. JRE is not sufficient.
solution : execute below command in your terminal
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
1.8.0_162, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk(your Java version)/Contents/Home
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
$ export PATH=$JAVA_HOME/bin:$PATH
$ R CMD javareconf
$ R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")'

R rJava Error on Mac when loading xlsx library [duplicate]

This question already has answers here:
rJava load error in RStudio/R after "upgrading" to OSX Yosemite
(18 answers)
Closed 5 years ago.
when I execute the following code on Mac, I got this
**> library(xlsx)**
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
Error: package ‘rJava’ could not be loaded
I saw some posts here that changes the directory of Java Home, but they are all in Windows system. I am wondering how can I fix this in a Mac environment?
Try this
If homebrew is not installed, install it from https://brew.sh/
Run this from terminal: brew cask install java
Reinstall rJava from R console
In general, and to avoid similar problems in the future, I suggest to follow my post to install R using homebrew http://pacha.hk/2017-07-12_r_and_python_via_homebrew.html
Doing that solves path problems and related stuff that can re-appear if later you want to use R database tools and related.

Error installing packages in R after messing with "pahts"

I was trying to install the rattle package in R and got this error message saying
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
Then I tried to fix the RGtk2 problem using this guide
http://marcoghislanzoni.com/blog/2014/08/29/solved-installing-rattle-r-3-1-mac-os-x-10-9/
I tried this code in the Mac OS terminal (but this is above my understanding) :
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
sudo port selfupdate
sudo port install pkgconfig
export PATH=/opt/pkgconfig/bin:$PATH
sudo port install gtk2 +x11
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
It gave me this answer
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
ad-mac0630:~ caruc35$ sudo port selfupdate
Password:
Sorry, try again.
Password:
And locked down.
I also installed XCode command line tools from Apple and tried some stuff from the guide above. It didnt get the rattle package to work so I erased it.
After messing with this the rattle package does still not work and R seems not to work as it did before. For example i can´t load the xlsx package getting this error message:
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 '/Users/caruc35/Library/R/3.4/library/rJava/libs/rJava.so':
dlopen(/Users/caruc35/Library/R/3.4/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Users/caruc35/Library/R/3.4/library/rJava/libs/rJava.so
Reason: image not found
Error: package ‘rJava’ could not be loaded
Did I mess up when trying to change PATH? Is there a way to reset everything back to normal?
I have tried reinstalling R but the same problems still occurs.

Rugarch Package on R don't load on mac laptop

I am having problems loading rugarch package on R and I really need that package for my thesis.
I have no problem installing it. But when I try to load it I receive the following error message:
Error : .onLoad failed in loadNamespace() for 'rgl', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/libs/rgl.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/libs/rgl.so
Reason: image not found
Error: package or namespace load failed for ‘rugarch’
Any suggestions ?
Any help would be appreciated.
This answer is a bit late but for other people searching for a solution. The solution that worked for me is to download and install XQuartz https://www.xquartz.org onto your Mac.
See Stackoverflow answers here and here

Resources