OK. From previous experience I've found there are not many instructions on how to install rpy2 on Windows. I get that it's not officially supported but it's really not that hard. In a few steps I'll show what I did and maybe others can follow.

These instructions will most likely only work for Python 2.7+ and R 3.2+ but will probably work for R 3.0+. I am putting the paths that I've used on my system. Make sure to modify the paths accordingly:

First, make sure any previous rpy2 installations are UNINSTALLED before trying these steps (and obviously have R 3.2+ before installing).

  1. Download the .whl file for r2py from here
  2. Install the .whl file using pip install [put .whl filename here] (in the command line) from the directory where the file was downloaded
  3. Append a path similar to C:\Program Files\R\R-3.2.0\bin to your PATH environment variable
  4. Create a R_HOME system variable with a value similar to: C:\Program Files\R\R-3.2.0
  5. Create a R_USER system variable with your user name
  6. Create a R_LIBS_USER system variable with a path to the folder where external R packages are/will be installed.

That's it. Open up a command prompt and enter the command R. This should start an R session and display version information.

Now open up python and run this line to see if things worked out or not:

import rpy2.robjects as robjects 

Hopefully this helps.


I just successfully installed rpy2 on Windows 8.1 64bit with the binary installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2. It is usually much easier to just download a binary instead of trying to compile a package in Windows.

Also, you should set R_HOME environmental variable (in my case, to C:\Program Files\R\R-3.1.1) before you install the rpy2 binary. Otherwise you get RuntimeError: R_HOME not defined. error when you try to import rpy2. (thanks to R_HOME Error with rpy2)

Lastly, make sure to use %load_ext rpy2.ipython instead of %load_ext rmagic if you want to use it in IPython. It is one of the new features in rpy2 version 2.4.0.

(thanks to IPython notebook and rmagic/rpy2: cannot find module ri2py (OSX 10.8.5, python 2.7, R 3.1))


I also generally had no success getting Rpy2 to work on Windows. After a few hours hacking around with R2.15 and Rpy2 from the pre-compiled binary 2.3.4.win-amd64-py2.7, I followed this question, and installed pyper instead. Maybe this will work for you until the support is there. I for one would love to see Rpy2 on Windows and IPython notebook (%load_ext rmagic), but I just couldn't spend any more time with it.


Following the answers above, this is what works for me

System: Win 7-64, Python 3.6,

1. Install R and packages you need

2. Set R_HOME and R_USER, as environment variable

R_HOME = D:\Program Files\R\R-3.4.1
R_USER = Administrator 

The user name can be obtained by echo %username% in cmd

3. Download rpy2 and install it

Download rpy2 from http://www.lfd.uci.edu/~gohlke/pythonlibs/

Check to its path, and install it in cmd like pip install rpy2-2.8.6-cp36-cp36m-win_amd64.whl

4. Create a notebook and see if it works

import rpy2.robjects as robjects

# test : evaluating R code
robjects.r('''
        # create a function `f`
        f <- function(r, verbose=FALSE) {
            if (verbose) {
                cat("I am calling f().\n")
            }
            2 * pi * r
        }
        # call the function `f` with argument value 3
        f(3)
        ''')