[R-gui] R-wxPython

Mpiktas mpiktas at delfi.lt
Tue Jun 15 15:41:17 CEST 2004


Hi,

> 
> 1. Install R with the shared library enabled.  (This can be
>     done with "configure --enable-shlib" when installing R
>     from source.  The shared library will normally appear in
>     /usr/local/lib/R/bin/libR.so)
>
In Debian this library comes with R package.

> 2. Install Python 2.2.x from source.  (RSPython doesn't seem to
>     like 2.3.x, so don't install that.  The reason I say to
>     install from source, is that you will need to create a
>     python shared library: libpython2.2.so, and this doesn't
>     seem to be distributed in the python RPM.)

I'm running Debian Sid and on my system python2.1, python2.2 and python2.3 are  
installed with their respective so libraries.

> 
> 3. Install RSPython 0.5-3 or later, being careful to link it
>     with the shared Python library, not a static library.
>     Check that RSPython.so depends on libpython2.2.so using
>     "ldd RSPython.so", and check that you have an
>     RSInternal.so symbolic link to RSPython.so in the
>     R/library/RSPython/libs/ directory.  To get RSPython
>     to link to libpython2.2.so, you may have to override the
>     automatic configure script, e.g.
>     "mv configure DONTconfigure" and manually edit Makefile,
>     Makevars, src/Makevars etc.

Fortunately I didn't have to change anything, except changing symlin /usr/bin/ 
python to point to /usr/bin/python2.2.

> 
> 4. Build wxPython 2.5.x from source (by first building
>      wxWidgets, distributed with wxPythonSrc).  You need to modify
>      wxPython/config.py as follows:
>        (i) Change self.root = "" to self.root = None
>        (ii) Change newLFLAGS=[] to
>               newLFLAGS = ['libpython2.2.so']
>      Copy libpython2.2.so to the wxPythonSrc/wxPython directory.
>      Note that you probably don't need all of the
>      optional-extras like OpenGL support, so you can build with
>      "python setup.py build CORE_ONLY=1" or
>      "python setup.py install CORE_ONLY=1" to just install the
>      essentials.
I've installed everything by using
python2.2 setup.py install --root=/usr/local/  WX_CONFIG=$WX_CONFIG  
WXPORT=gtk2 UNICODE=1

and then copying respective files to /usr/local/lib/python2.2/site-packages/,
because contrary to manual in
http://www.wxpython.org/INSTALL.html
everything was installed in directory /usr/local/usr/ instead of /usr/local.

> 
> 5. Make sure that the new shared libraries are included in
>      LD_LIBRARY_PATH and have been registered with
>      /sbin/ldconfig.  Some Linux systems allow you to do this
>      without root privileges, while others don't.  I don't
>      have a root password, so I work mostly in my home area:
>      ~/usr/ etc. but occasionally I need to ask for help from
>      root.
> 
> 6. Run ldd on the wxPython shared libraries in
>      /usr/local/lib/python2.2/site-packages/wx/ or wherever,
>      to check that they depend on libpython2.2.so, otherwise you
>      will get errors like "Undefined symbol PyExc_IOError".
> 
> In R, type:
> library(RSPython)
> 
> Ignore the following warning:
> "the Python callback manager has been registered implicitly
> using the defaults (referenceManager())!"
> 
> [We will use the wxPython 2.4.x method of importing the wx
> module. In order understand the difference between
> importPythonModule("wxPython.wx") and importPythonModule("wx"),
> please read:
> http://www.wxpython.org/migrationguide.php ]
> 
> Try importing the wxPython.wx module:
> 
> importPythonModule("wxPython.wx")
> 
> If it returns NULL with no errors, then it succeeded.  If it
> cannot be found, check your PYTHONPATH environment variable,
> and if necessary, modify the Python search path within R
> as follows:
> importPythonModule("sys")
> .Python("path",.module="sys") # Check the current Python path.
> path <- "/usr/local/lib/python2.2/site-packages/wx"
> .PythonEval(paste("path.append('",path,"')",sep=""),.module="sys")
> # Repeat for other paths you want to add.

In my case .Python("path",.module="sys") produced
 [1] "/usr/local/lib/R/site-library/RSPython/Python"
 [2] "/usr/local/lib/R/site-library/RSPython/libs"
 [3] "/usr/lib/python2.2"
 [4] "/usr/lib/python2.2/plat-linux2"
 [5] "/usr/lib/python2.2/lib-tk"
 [6] "/usr/lib/python2.2/lib-dynload"
 [7] "/usr/local/lib/python2.2/site-packages"
 [8] "/usr/lib/python2.2/site-packages"
 [9] "/usr/lib/python2.2/site-packages/Numeric"
[10] "/usr/lib/python2.2/site-packages/gtk-2.0"
[11] "/usr/lib/site-python"

and importPythonModule("wxPython.wx") worked, without changing anything.

> 
> Now create a simple wxPython module, testRwxPy.py :
> -----------------------------
> import wxPython.wx
> from wxPython.wx import *
> 
> def wxRPyApp():
>         app = wxApp()
>         return app
> -----------------------------
> 
> Make sure testRwxPy.py can be found in your Python search path,
> (using the technique above) and try:
> 
> .Python("wxRPyApp",.module="testRwxPy")
> 
> When running under R -d gdb, I get a segmentation fault which
> appears to come from gdk_init_check().  :-(

I got
Failing in conversion from Python object: Unhandled case!
NULL

and no segmentation fault. Is this suppose to happen or not? Feel free to ask  
for any details. Hope this report helps somehow.

Vaidotas Zemlys



More information about the R-SIG-GUI mailing list