R_GlobalEnv
not being found.
To build the shared library, you will need to compile
R from scratch and configure it with the
--enable-R-shlib
flag.
pthread_sigmask
, e.g.
Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library "/tmp/R/pkg/RSPython/libs/RSPython.so": /tmp/R/pkg/RSPython/libs/RSPython.so: undefined symbol: pthread_sigmask Error in library(RSPython) : .First.lib failed
R CMD INSTALL -c --configure-args='--with-threads' RSPython
openpty
, e.g.
> library(RSPython) Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library "/tmp/R/pkg/RSPython/libs/RSPython.so": /tmp/R/pkg/RSPython/libs/RSPython.so: undefined symbol: openpty Error in library(RSPython) : .First.lib failed
-lutil
to the end of the PKG_LIBS variable
setting
in src/Makevars.in and
re-install the package.
R_X11.so
and that is failing. (It attempts to find symbols
in R, but the way that R is loaded into Python means
it cannot find them! It is a dynamic loading issue.)
libR.so
.
Currently, the simplest thing to do is edit the
file src/unix/X11/Makefile and specifically the
$(SHLIB)
rule.
All you need to do is add -L$(R_HOME)/bin -lR
in the link command.
So, it should look like
$(SHLIB): $(OBJECTS) $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) -L$(R_HOME)/bin -lR $(ALL_LIBS)Then invoking make in that directory should create the
R_X11
shared library
(R_X11.so
many systems)
in $R_HOME/bin
.
import RScommand to load R, I get the error
>>> import RS; Traceback (innermost last): File "", line 1, in ? ImportError: libR.so: cannot open shared object file: No such file or directory
LD_LIBRARY_PATH
environment variable
set correctly when you run python.
You can do this with
setenv LD_LIBRARY_PATH $R_HOME/bin #csh and tcsh export LD_LIBRARY_PATH=$R_HOME/bin # bashand the run python.
Note that you cannot set the value of LD_LIBRARY_PATH from within python and have it take effect. That is
% python >>> from os import environ >>> environ['LD_LIBRARY_PATH'] = environ['R_HOME']+ "/bin" >>> import RSwill not work.
R_X11.so
compiled as in the question
above (i.e. linking against libR.so
),
it should be as simple as
RS.call("plot", [1,2,3])
import RScommand to load R, I get the error
>>> import RS Fatal error: R home directory is not defined
R RHOMEbefore importing the RS module.
import RSgives an error message
ImportError: No module named RS
PYTHONPATH
correctly.
This variable must include the fully qualified directories Python/
and libs/
of the directory into which the
R package was installed.
Also, take a look at the return value from
import sys sys.pathThe latest version now tries to set this automatically for you. See
.PythonPath()
.