rpy2 install on windows 7
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).
- Download the .whl file for r2py from here
- Install the .whl file using
pip install [put .whl filename here]
(in the command line) from the directory where the file was downloaded - Append a path similar to
C:\Program Files\R\R-3.2.0\bin
to your PATH environment variable - Create a
R_HOME
system variable with a value similar to:C:\Program Files\R\R-3.2.0
- Create a
R_USER
system variable with your user name - 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.