69.3 Installing RSPython

$ wget http://www.omegahat.org/RSPython/RSPython_0.5-1.tar.gz

Then install RSPython in R:

$ sudo R CMD INSTALL --clean RSPython_0.5-1.tar.gz

This command, executed as the root user has then installed the required files into /usr/lib/R/library/RSPython. To communicate where the files are installed to Python we need to set up three environment variables (a Debian package would probably set this up so that these extra environment variables are not required), and then run Python and try out some RSPython calls:

  $ export R_HOME=/usr/lib/R
  $ export PYTHONPATH=${R_HOME}/library/RSPython/Python
  $ export PYTHONPATH=${PYTHONPATH}:${R_HOME}/library/RSPython/libs
  $ export LD_LIBRARY_PATH=${R_HOME}/bin
  $ python
  Python 2.2.1 (#2, Sep 13 2002, 23:25:07) 
  [GCC 2.95.4 20011002 (Debian prerelease)] on linux2
  Type "help", "copyright", "credits" or "license" for more information. 
  >>> import RS
  Initialized R-Python interface package. 
  >>> RS.call("rnorm", 10)
  [-0.65567988872831473, 0.67905969371540564, -1.1444361954473865, 
   0.81452303045337249, 0.72703311800839554, 0.86401079894005484, 
   -2.0267500136837922, 1.3879521193129922, -0.59819064121768595, 
   1.1045450495203162]
  >>> RS.call("plot", [1,2,3,4])
  >>> RS.call("plot", RS.call("rnorm",10))
  >>> ^D

If you get:

  $ python
  >>> import RS
  Traceback (most recent call last):
    File "<stdin>", line 1, in ? 
    File "/usr/lib/R/library/RSPython/Python/RS.py", line 1, in ? 
      import RSInternal
  ImportError: /usr/lib/atlas/libblas.so.2: undefined symbol: e_wsfe
  >>> 

Then be sure that you don’t have atlas2-base installed:

  $ wajig remove atlas2-base

69.3.1 Installing RPy

For sophisticated plotting using the R package see Chapter ??.

Install python-rpy.

Older approaches did:

  $ wajig install rpy_0.3.1-1_i386.deb
  $ (cd /usr/lib; sudo ln -s R/bin/libR.so)

Then test it with:

  $ python
  Python 2.3.1 (#2, Sep 24 2003, 11:39:14)
  [GCC 3.3.2 20030908 (Debian prerelease)] on linux2
  Type "help", "copyright", "credits" or "license" for more information. 
  >>> from rpy import *
  >>> l = [r.dchisq(x, 4) for x in r.seq(0, 10, by=0.1)]
  >>> r.par(ask=1, ann=0)
  {'ask': 0, 'ann': 1}
  >>> r.plot(l, type='lines')
  Hit <Return> to see next plot:
  >>> r.dev_off()
  {'null device': 1}
  >>> ^D

To install it by hand until rpy debian package is released:

  $ cd /tmp
  $ wget http://easynews.dl.sourceforge.net/sourceforge/rpy/rpy-0.2.tar.gz
  $ tar zxvf rpy-0.2.tar.gz
  $ cd rpy-0.2
  $ sudo python setup.py install
  $ sudo emacs -nw /etc/ld.so.conf
  Add the line:
  /usr/lib/R/bin
  $ sudo ldconfig
  $ python
  Python 2.2.1 (#2, Sep  7 2002, 15:35:22) 
  [GCC 2.95.4 20011002 (Debian prerelease)] on linux2
  Type "help", "copyright", "credits" or "license" for more information. 
  >>> from rpy import *
  >>> l = [r.dchisq(x, 4) for x in r.seq(0, 10, by=0.1)]
  >>> r.par(ask=1, ann=0)
  >>> r.plot(l, type='lines')
  >>> ^D
  $ cd .. 
  $ sudo rm -rf rpy-0.2*

For earlier versions of rpy I used to get:

  $ python
  >>> from rpy imprt *
  Traceback (most recent call last):
    File "<stdin>", line 1, in ? 
    File "rpy.py", line 24, in ? 
      import _rpy
  ImportError: /usr/lib/atlas/libblas.so.2: undefined symbol: e_wsfe
  >>> 

then you needed to remove atlas2-base:

  $ wajig remove atlas2-base

However, more recently this packages is actually required to run R and rpy!

With version 0.3.1 of rpy I get the following (11 Aug 03):

  $ python2.2
  Python 2.2.3+ (#1, Aug 10 2003, 10:11:23) 
  [GCC 3.3.1 (Debian)] on linux2
  Type "help", "copyright", "credits" or "license" for more information. 
  >>> import rpy
  Traceback (most recent call last):
    File "<stdin>", line 1, in ? 
    File "/usr/lib/python2.2/site-packages/rpy.py", line 24, in ? 
      import _rpy
  ImportError: /usr/lib/python2.2/site-packages/_rpymodule.so: 
      undefined symbol: jump_now
  >>>

Also happens for python2.3 (11 Aug 2003).



Your donation will support ongoing availability and give you access to the PDF version of the book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.