Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing rpy2 without admin privileges

Tags:

python

r

gcc

rpy2

I am having trouble installing the Python package rpy2. I have already compiled R as a shared library, but I do not have admin priviledges so I am trying to install rpy2 with:

pip install -user rpy2

However, I am getting the following error:

./rpy/rinterface/_rinterface.c:86:31: fatal error: readline/readline.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

I have downloaded readline to:

/some/path/readline-6.2/

where I can see readline.h (I have also compiled readline just in case)

My question:

How can I make rpy2 (or pip) aware of this location with readline.h to avoid the header compilation error?

like image 722
Amelio Vazquez-Reina Avatar asked Nov 27 '22 09:11

Amelio Vazquez-Reina


2 Answers

You'll need to actually install readline, not just download it, and then point rpy2 to it with CFLAGS and LDFLAGS.

Try this approach. It's almost working for me - I have the same problem, except an additional wrinkle that rpy2 seems to be linking against the system R instead of my homedir install.

First, I downloaded readline to ~/src/readline-6.2, and installed it with ./configure --prefix=$HOME && make && make install. (You need to install it somewhere, not just download the source.)

Then I re-compiled R with

CPPFLAGS="-I/usr/local/include -I$HOME/include/" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L$HOME/lib64 -L$HOME/lib" \
./configure --prefix=$HOME --enable-BLAS-shlib --enable-R-shlib
make
make install

R is definitely now using that readline:

$ ldd ~/lib64/R/lib/libR.so | grep readline
libreadline.so.6 => /home/dsutherl/lib/libreadline.so.6 (0x00007f8104207000)

The same for my in-home install of Python (3.2.3, since h5py doesn't work with 3.3 yet):

CFLAGS="-I/usr/local/include -I$HOME/include/" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L$HOME/lib64 -L$HOME/lib" \
./configure --prefix=$HOME
make
make install

And again:

$ ldd ~/lib/python3.2/lib-dynload/readline.cpython-32m.so | grep readline
libreadline.so.6 => /home/dsutherl/lib/libreadline.so.6 (0x00007fbfff5c2000)

Then I downloaded the rpy2 source and built that:

CFLAGS="-I/usr/local/include -I$HOME/include/" \
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L$HOME/lib64 -L$HOME/lib" \
python3 setup.py build --r-home $HOME/lib64/R install

This seemed successful, and ldding the .sos in site-packages/rpy2 links to the right libreadline...but to the system R, instead of mine, despite the explicit --r-home.

like image 191
Danica Avatar answered Nov 29 '22 03:11

Danica


more simple :

yum install readline-devel.x86_64

run for me on centos 7

for debian/ubuntu

apt-get install libreadline-dev
like image 21
Fabrice Carles Avatar answered Nov 29 '22 04:11

Fabrice Carles