4

I'm running Python v2.7.8 and R v3.0.2 (2013-09-25) -- "Frisbee Sailing" on my elementary OS Freya 64 bit (based on Ubuntu 14.04).

I'm trying to install the rpy2 package with:

pip install rpy2

and it fails with the error:

Failed building wheel for rpy2

Down below I also see:

error: command 'gcc' failed with exit status 1

The full output is here.

I've already tried:

sudo apt-get install python-dev libevent-dev python3-dev

but the error remains.

I know pip works because I've already installed numpy, matplotlib, scipy, and other packages using it.

Gabriel
  • 40,504
  • 73
  • 230
  • 404

5 Answers5

7

Found the answer in this post. I just had to upgrade R from v3.0.2 to the latest version available for my system (v3.2.1).

Step 1: Uninstall Previous R-base installation

sudo apt-get remove r-base-core

Step 2: Update Sources.List File

  1. Edit the sources.list file

    sudo gedit /etc/apt/sources.list
    
  2. Add following entry (for Ubuntu 14.04):

    deb http://cran.rstudio.com/bin/linux/ubuntu trusty/
    

Step 3: Add the Public Keys

gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -

Step 4: Install R-base

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install r-base

Step5: install rpy2

pip install rpy2
Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • 1
    This solution (upgrading R from v3.0.2 to v3.2.1) solved the same problem I was having on Mac (Mavericks). Didn't do Steps 1-4; just installed new version of R and then `pip install rpy2` as root. – Kappa Jul 24 '15 at 17:21
2

It is indicated in the full output.

It has to do with how R was compiled and/or installed. Rpy2 is expecting a header that cannot be found:

   ./rpy/rinterface/r_utils.c:32:31: fatal error: R_ext/Rallocators.h: No existe el archivo o el directorio
 #include <R_ext/Rallocators.h>
lgautier
  • 11,363
  • 29
  • 42
  • Thanks lgautier, any idea on how to fix that given that I've already installed the usual 'dev' packages? – Gabriel Jul 22 '15 at 12:48
  • It was because of the R version. I have to update the check of the R version: https://bitbucket.org/rpy2/rpy2/issues/291/check-that-r-32-is-used-to-build – lgautier Jul 29 '15 at 00:44
0

This solution worked for me because it's actually a header issue: https://stackoverflow.com/a/23085474/7049567

sudo apt-get install libreadline-dev 

Or

yum install readline-devel
Paul Bendevis
  • 2,381
  • 2
  • 31
  • 42
0

apt-get install -y python3-rpy2

Stefan
  • 10,010
  • 7
  • 61
  • 117
0

For people wondering, in Fedora, you need to install this package:

sudo dnf install python3-devel

This will solve the problem if you have a header issue! Pip is trying to compile rpy2, thus it needs a header file. The header file is within this package!

Stopfield
  • 1
  • 3