Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 3rd party python geoprocessing script that requires rpy2, and thus also . What is the best way to get these working together?

Using R with ArcGIS Desktop says the most useful option for using R with ArcGIS is via the Geospatial Modelling Environment but as near as I can tell GME doesn't use rpy2. The script I'd like to use is not that large, but I didn't write it and don't want to port it to a different module. I don't understand the workings well enough to be confident I could do so without making a mistake.

share|improve this question

The script should work if you have R and rpy2 installed properly. First install R, then rpy2, and be sure that you update your PATH with the rpy2 location.


Depending how explicit the third-party script is in importing the rpy2 module you may need to set the RHOME path thusly:

from rpy_options import set_options
set_options(RHOME='C:\\Program Files\\R\\R-2.13.1\\')
share|improve this answer
Could you elaborate more on how you managed to install rpy2? Getting errors during installation. – R.K. Sep 16 '12 at 3:47

Installing rpy2 in windows can be rather complex. Here are the instructions that worked for me:

1. Install R

2. Install Rtools

3. Define environmental variables
Control Panel | Advanced tab | Environmental Variables

define the following: RHOME, R_HOME, R_USER

RHOME: C:\Program Files\R\R-2.13.1
R_HOME: C:\Program Files\R\R-2.13.1
R_USER: C:\Users\username\Documents

4. Append path to R (and Rtools) executable(s) to PATH
Control Panel | Advanced tab | Environmental Variables

example paths: C:\Program Files\R\R-2.13.1\bin\i386; C:\Rtools\bin

5. Build rpy2
1. Download and execute the binary executable 


2. Download the source and build:

In the rpy2 folder...

python build --force -c mingw32
python install

Adapted from

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.