A question for a (experienced) user of the RPython package on linux. I'm trying to call R from python on a linux (Suse 7.3) box. After installing R CMD INSTALL -c RSPython_0.5-2.tar.gz I start python and do:>>> import sys >>> sys.path.append('/usr/local/lib/R/library/RSPython') >>> sys.path.append('/usr/local/lib/R/library/RSPython/Python') >>> sys.path.append('/usr/local/lib/R/library/RSPython/libs') >>> sys.path.append('/usr/local/lib/R/library/RSPython/man') >>> sys.path.append('/usr/local/lib/R/library/R/RSPython') >>> sys.path.append('/usr/local/lib/R/library/RSPython/R/RSPython') >>> sys.path.append('/usr/local/lib/R/library/RSPython/R') >>> sys.path.append('/usr/local/lib/R/library/RSPython/include') >>> sys.path.append('/usr/local/lib/R/include/R_ext') >>> import RSTraceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/R/library/RSPython/Python/RS.py", line 1, in ? import RSInternal ImportError: /usr/local/lib/R/library/RSPython/libs/RSInternal.so: undefined symbol: R_GlobalEnv>>> import RS >>> RS.call("rnorm", 10);Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'RS' module has no attribute 'call' Any idea of what am I doing wrong? Where should R_GlobalEnv be defined? Thanks Agus Dr. Agustin Lobo Instituto de Ciencias de la Tierra (CSIC) Lluis Sole Sabaris s/n 08028 Barcelona SPAIN tel 34 93409 5410 fax 34 93411 0012 alobo at ija.csic.es
My immediate guess is that you do not have R compiled as a shared library, i.e. libR.so. Without this, you cannot use R within Python, but only Python within R. libR.so is where R_GlobalEnv will come from. So check for libR.so in the directory `R RHOME`/bin. If it is not there, you will have to build R from source by configuring it with ./configure --enable-R-shlib Then, re-install the RSPython package and things should work. There is a shell script in the scripts/ directory of the installed RSPython package that sets the relevant variables. Just source that into your shell (i.e. source for csh/tcsh, or . sciptName for Bash) and that should set the PYTHONLIB and LD_LIBRARY_PATH correctly. D. Agustin Lobo wrote:> A question for a (experienced) user of the RPython package on > linux. > > I'm trying to call R from python on a linux (Suse 7.3) box. > > After installing R CMD INSTALL -c RSPython_0.5-2.tar.gz > > I start python and do: > > >>> import sys > >>> sys.path.append('/usr/local/lib/R/library/RSPython') > >>> sys.path.append('/usr/local/lib/R/library/RSPython/Python') > >>> sys.path.append('/usr/local/lib/R/library/RSPython/libs') > >>> sys.path.append('/usr/local/lib/R/library/RSPython/man') > >>> sys.path.append('/usr/local/lib/R/library/R/RSPython') > >>> sys.path.append('/usr/local/lib/R/library/RSPython/R/RSPython') > >>> sys.path.append('/usr/local/lib/R/library/RSPython/R') > >>> sys.path.append('/usr/local/lib/R/library/RSPython/include') > >>> sys.path.append('/usr/local/lib/R/include/R_ext') > >>> import RS > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/local/lib/R/library/RSPython/Python/RS.py", line 1, in ? > import RSInternal > ImportError: /usr/local/lib/R/library/RSPython/libs/RSInternal.so: > undefined symbol: R_GlobalEnv > >>> import RS > >>> RS.call("rnorm", 10); > Traceback (most recent call last): > File "<stdin>", line 1, in ? > AttributeError: 'RS' module has no attribute 'call' > > Any idea of what am I doing wrong? Where should R_GlobalEnv > be defined? > > Thanks > > Agus > > Dr. Agustin Lobo > Instituto de Ciencias de la Tierra (CSIC) > Lluis Sole Sabaris s/n > 08028 Barcelona SPAIN > tel 34 93409 5410 > fax 34 93411 0012 > alobo at ija.csic.es > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help-- _______________________________________________________________ Duncan Temple Lang duncan at research.bell-labs.com Bell Labs, Lucent Technologies office: (908)582-3217 700 Mountain Avenue, Room 2C-259 fax: (908)582-3340 Murray Hill, NJ 07974-2070 http://cm.bell-labs.com/stat/duncan
Agustin Lobo wrote:> > A question for a (experienced) user of the RPython package on > linux. > > I'm trying to call R from python on a linux (Suse 7.3) box.Since you are calling R from Python, you could try Walter Moreira's excellent RPy module. I found it much easier to install than RSPython (provided you follow Waletr's instructions), and it has been very reliable. It is also very efficient at converting Numeric Python arrays to R, and has a very easy to use object model - much nicer than RSPython's. See http://rpy.sourceforge.net Of course, RSPython can also call Python from R, which RPy can't do. Tim C
I'm working in WinXP. Is it the case that RSPython does not work on Win32 platforms? I believe I read this somewhere... I'd appreciate confirmation. Either way, I wasn't able to get RSPython to work for me, this was some time ago, and at that time I was very new to Python. Thanks. -----Original Message----- From: Tim Churches [mailto:tchur at optushome.com.au] Sent: Monday, December 23, 2002 23:03 To: Agustin Lobo Cc: r-help Subject: Re: [R] calling R from python (fwd) Agustin Lobo wrote:> > A question for a (experienced) user of the RPython package on > linux. > > I'm trying to call R from python on a linux (Suse 7.3) box.Since you are calling R from Python, you could try Walter Moreira's excellent RPy module. I found it much easier to install than RSPython (provided you follow Waletr's instructions), and it has been very reliable. It is also very efficient at converting Numeric Python arrays to R, and has a very easy to use object model - much nicer than RSPython's. See http://rpy.sourceforge.net Of course, RSPython can also call Python from R, which RPy can't do. Tim C ______________________________________________ R-help at stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
After reading the documentation, I believe the problem may be specific to me. Either way, I'll have to investigate further, and I'll provide more details next time, if I'm unable to get things to work. In the meantime, suggestions & tips are always welcome. Thanks again. Samir. -----Original Message----- I'm working in WinXP. Is it the case that RSPython does not work on Win32 platforms? I believe I read this somewhere... I'd appreciate confirmation. Either way, I wasn't able to get RSPython to work for me, this was some time ago, and at that time I was very new to Python. Thanks.