rPython & Anaconda

Nota: publico hoy en inglés en atención al público potencial de la entrada.

rPython lets R users call Python code. Anaconda is a completely free enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing. Not surprisingly, some users want to call Anaconda Python rather than their system’s default Python.

However, Anaconda is a very particular package: unlike most other packages, whose files are scattered in a diversity of locations, it is self contained in a single directory. This helps Anaconda solve some problems, like the library hell. It is intended to provide the same experience regardless of the specifics of the host system.

But this does not come for free. Problems arise, for instance, when one wants to dynamically link against Anaconda Python. This is precisely what rPython intends: when rPython is installed, it will —if the proper configuration parameters are provided— compile against Anaconda Python libraries. So far so good.

However, when it is loaded (via library(rPython)), it will search for the right Python library (e.g., libpython2.7.so.1.0) inside the directories listed in the environment variable LD_LIBRARY_PATH (in fact, it is a bit more complicated than that, but let’s forget the details) and try to dynamically load it. But because of Anaconda’s DIY (or autistic) design, $ANACONDA_HOME/lib will not be found there.

Options? For instance, you can ldconfig to register Anaconda libs in the system (but do beware of unintended side effects!). You can also try to add $ANACONDA_HOME/lib to /etc/R/ldpaths, but something may also break; in my case, R refuses to start, in fact.

In summary, I have no idea how to solve this problem. But perhaps some of my readers know!