[Rd] RSPython
Duncan Temple Lang
duncan at wald.ucdavis.edu
Thu Feb 12 00:42:58 CET 2009
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
More information about the R-devel
mailing list