On 10/18/2013 10:35 PM, Laurent Gautier wrote:
On 10/18/2013 06:25 PM, Alessandro Gagliardi wrote:
I would like to be able to access a MS SQL Server Database in R through IPython Notebook. I've been able to get RJDBC to work in R natively, but when I try to load the library through magic (I.e. rpy2), I get the following error:
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: dyn.load(file, DLLpath = DLLpath, ...)
   error: unable to load shared object 
'/usr/local/lib/R/site-library/rJava/libs/rJava.so':
   libjvm.so: cannot open shared object file: No such file or directory
Error: package 'rJava' could not be loaded
It would seem that when R is being run through rpy2 it cannot find libjvm.so. Any help would be much appreciated.

I can reproduce it here. I would need to spend a bit of time to investigate what is exactly happening.

In the meantime, setting your LD_LIBRARY_PATH seemd to be a workaround.

1- Get what path for Java R feels good with:
$ R CMD config JAVA_LIBS
-L/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server -ljvm

2- Set LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server:${LD_LIBRARY_PATH}

Now start python/ipython.



More on this. This is an issue around environment variables, R, and Java, it seems.

An other way to solve the problem is to run the following right before starting Python / ipython:

$ R CMD javareconf -e

What seems to be happening is that when one writes "R" in terminal a shell script is executed, setting few environment variables before calling a binary for R.
LD_LIBRARY_PATH is tweaked at that moment. See:

||cat `R RHOME`/etc/ldpaths

This script is obviously not executed when running an embedded R, which explains the difference in behaviour between importing rJava from R, and from rpy2 (embedded R).

I have opened an issue ( https://bitbucket.org/lgautier/rpy2/issue/158/error-when-importing-rjava ).


L.



Laurent


Thank you,
Alessandro Gagliardi
Sr. Data Scientist, Glassdoor.com
alessandro.gaglia...@glassdoor.com <mailto:alessandro.gaglia...@glassdoor.com>


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk


_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to