Re: [Rd] RSPython

From: Duncan Temple Lang <duncan_at_wald.ucdavis.edu>
Date: Wed, 11 Feb 2009 15:42:58 -0800

Hi David.

(Sorry about not replying to your earlier mail. I have been rather busy in the last few days.)

David Scherrer wrote:
> Hi all,
>
> I try to utilize RSPython to invoke Python from R. For me it works pretty
> fine for basic applications, but I have 3 problems that may be related.
>
> (1) I can't load other packages but "standard" ones also when I adjust the
> PythonPath:
>
> > importPythonModule('sys', all=T)
> NULL
>
> > importPythonModule('numpy', all=T)
> Error in .PythonEval(cmd) :
> Error in Python call:
> /usr/lib/python2.5/site-packages/numpy/core/multiarray.so: undefined symbol:
> _Py_ZeroStruct

I imagine that this is as a result of the Python modules you are loading containing compiled code and that these were not linked against the Python shared library when they were installed. As a result, they refer to symbols in the Python library, but these symbols are unresolved (e.g. use nm to look at the undefined symbols). When these modules are loaded into Python, Python provides those symbols as part of its "main" library. In our case, R is the main application/library and does not export the Python symbols which are loaded and squirrelled away in a separate compartment.

The best thing to do is install the Python modules so that they link against libpython.so.

The practical thing to try, however, is to load libpython.so into R with

  dyn.load("/where/ever/libpython.so", local = FALSE)

before you load RSPython, or before you use importPythonModule().

>
> > importPythonModule('Scientific.Functions.Derivatives', all=T)
> Error in .PythonEval(cmd) :
> Error in Python call:
> /usr/lib/python2.5/site-packages/Scientific/linux2/Scientific_numerics_package_id.so:
> undefined symbol: PyString_InternFromString
>
>
> (2) I can't even load the test example provided at www.omegahat.org/*
> RSPython*/ <http://www.omegahat.org/RSPython/> .
>
> >
> Sys.putenv("PYTHONPATH"='/usr/local/lib/R/site-library/RSPython/tests')
> > .PythonInit()
> > test <- .PythonNew("RSTest", .module="method")
> Error in .PythonNew("RSTest", .module = "method") : No such module

Is that module installed in /usr/local/lib/R/site-library/RSPython/tests

>
>
> (3) It doesn't find RS.so if I try dyn.load("RS.so")

      Well you'll need to give it a path. In what context are you doing this?

    D.

>
> My OS is Linux Debian (kernel 2.6.27-11-generic) .
>
> Many thanks for you help!
>
> David
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 11 Feb 2009 - 22:46:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Feb 2009 - 08:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive