Re: [Rd] RSPython

From: Duncan Temple Lang <>
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)
> > importPythonModule('numpy', all=T)
> Error in .PythonEval(cmd) :
> Error in Python call:
> /usr/lib/python2.5/site-packages/numpy/core/ 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

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

  dyn.load("/where/ever/", 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/
> undefined symbol: PyString_InternFromString
> (2) I can't even load the test example provided at*
> 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 if I try dyn.load("")

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


> My OS is Linux Debian (kernel 2.6.27-11-generic) .
> Many thanks for you help!
> David
> [[alternative HTML version deleted]]
> ______________________________________________
> mailing list
> mailing list 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 Please read the posting guide before posting to the list.

list of date sections of archive