1

I have tried every install method I can think of to install RPy2 on our debian server and I get the same message regardless. I have installed and used it successfully on my mac. Is there something I may be missing?

start

Processing rpy2
Running setup.py -q bdist_egg --dist-dir /opt/rpy2/egg-dist-tmp-oft2ko

returned an empty string.


returned an empty string.

Configuration for R as a library:
  include_dirs: ('/usr/share/R/include',)
  libraries: ('R',)
  library_dirs: ('/usr/lib64/R/lib',)
  extra_link_args: ()
 # OSX-specific (included in extra_link_args)
  framework_dirs: ()
  frameworks: ()
warning: no previously-included files matching '*patch*' found anywhere in distribution
warning: no previously-included files matching '*diff*' found anywhere in distribution
warning: no previously-included files matching '.hg' found anywhere in distribution
warning: no files found matching 'MANIFEST

'

. . .

end

./rpy/rinterface/_rinterface.c:3622: error: ‘embeddedR_isInitialized’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c:3622: error: ‘Py_False’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c:3634: error: ‘Py_None’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c:3635: error: ‘PySexpObject’ has no member named ‘sObj’
./rpy/rinterface/_rinterface.c:3637: error: expected expression before ‘)’ token
./rpy/rinterface/_rinterface.c:3650: error: ‘PySexpObject’ has no member named ‘sObj’
./rpy/rinterface/_rinterface.c:3652: error: expected expression before ‘)’ token
./rpy/rinterface/_rinterface.c:3665: error: ‘PySexpObject’ has no member named ‘sObj’
./rpy/rinterface/_rinterface.c:3667: error: expected expression before ‘)’ token
./rpy/rinterface/_rinterface.c:3680: error: expected expression before ‘)’ token
./rpy/rinterface/_rinterface.c:3694: error: expected expression before ‘)’ token
./rpy/rinterface/_rinterface.c:3705: error: ‘rinterface_unserialize’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c:3705: warning: implicit declaration of function ‘PyDict_GetItemString’
error: Setup script exited with error: command 'gcc' failed with exit status 1

Thank you for the help

GreatGather
  • 861
  • 2
  • 11
  • 24

3 Answers3

9

Please try

sudo apt-get install python-rpy2

(or use whichever packaging frontend you prefer) as the package exists within the distribution.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Seems like you are new here. What you ask the person asking are expected to do is two things: "upvote" the answer if you like it by clicking on the uparrow. "accept" the answer if you like it by clicking on the tickmark. You can do either or both (which is common for answers judged "good"). – Dirk Eddelbuettel Jun 28 '12 at 22:02
  • Would you consider `sudo apt install python3-rpy2` the official/supported way to install rpy2 on Debian? Rather than `pip install rpy2`? Would you expect apt and pip to both work out of the work in `python`? I am on Debian, previously MS Windows. I remember having issues with importing a package in python via rpy2 because R stored the packages somewhere (somewhere around /documents) else than where rpy2 looked for it (somewhere around /programs or /program files). – Johan May 04 '23 at 16:40
  • 1
    Binary packages are great. That's why I still maintain them -- I have been a Debian contributor doing this for over 25 years now. One issue I sometimes is to blend the desire of a stable release (Debian stable, Ubuntu LTS) with current releases. That can be an issue. But if you are eg on Debian testing or roll Ubuntu every six months (I do) then you are pretty good. And for 'brand new things' I sometimes use Ubuntu PPAs. So yes, "works for me". – Dirk Eddelbuettel May 04 '23 at 16:40
  • 1
    But note that the answer was also in response to someone failng to install from source (which can be tricky). Working binaries are generally great there as working alternative. – Dirk Eddelbuettel May 04 '23 at 16:42
  • Thanks! Should I ask a new question about this? .... else: I did not understand: how would I be good - with what combination of debian stable/test and apt/pip? On my end, and I'm on stable bullseye, apt finds python3-rpy2 (3.4.2-1) whereas pip finds rpy2 3.5.11. The rpy2 website suggests using pip. Otherwise, if I have to try to edit the path, can I get back to you for advice e.g. whether to edit path of python env or R/rpy2 env? – Johan May 04 '23 at 16:55
  • 1
    This is not the time or place: a side thread of an eleven year-old question is not where you have an extended discussion. Maybe an issue at the rpy2 repo, maybe a question on the r-sig-debian list (this is an R question too so it fits AFAIC). – Dirk Eddelbuettel May 04 '23 at 18:22
0

If you compile R with

./configure --enable-R-shlib, then R is installed in /usr/local/lib/R

So you can add this lines to .bashrc, for you and root user

export R_HOME=/usr/local/lib/R
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$R_HOME/lib

Then you can install from pip or build from tarball

friveroll
  • 386
  • 2
  • 3
  • 15
0

As pointed in rpy2 installation on Ubuntu, sometimes a missing python-dev (python-devel in RHEL) may cause these issues. You can fix by either

    sudo apt-get install python-dev

or

    sudo yum install python-devel

Or other OS specific instruction for installing python-dev[el]

Community
  • 1
  • 1
nom-mon-ir
  • 3,748
  • 8
  • 26
  • 42