Python – Installing rpy2 returns an error

Installing rpy2 returns an error… here is a solution to the problem.

Installing rpy2 returns an error

I’m using Debian-based Linux and trying to install rpy2 using pip3.

When type:

sudo pip3 install rpy2

I see

user@huayra:~$ sudo pip3 install rpy2
Collecting rpy2
  Using cached rpy2-2.9.2.tar.gz
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no command 'R' in the PATH.
  ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-r6axcg8n/rpy2/

I installed pip3 and the version is:

pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)

Edit

After some updates, I rerun the command sudo pip3 install rpy2 and get:

    Error: R >= 3.3 required (and the R we found is '3.1.1').
    R version 3.1.1 (2014-07-10) -- "Sock it to Me"     
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-3n_yfk5i/rpy2/

Does it help?

Solution

The package has been part of the distro for years – I’m the maintainer.

So be it

  • sudo apt-get install python-rpy2(Python 2 on e.g. Debian stable)
  • sudo apt-get install python3-rpy2 (Python 3, available everywhere).

It introduces all the required dependencies as usual.

Related Problems and Solutions