title: Rpy2 Cannot Find R.dll
body: <p>I am on Windows 7 64bit with Python 2.7.9, have installed R-3.2.0 (also previously tried R-2.12.2 and R-3.1.3 but got the same result), added <code>C:\Program Files\R\R-3.2.0\bin\i386</code> to the system path, added R_HOME as a system variable with value <code>C:\Program Files\R\R-3.2.0</code>, added R_USER with value "Matt", and installed rpy2-2.3.0dev with a .exe file, which installed.</p>
  
  <p>However, typing <code>from rpy2 import robjects</code> gives the following error in rpy2\rinterface\__init__.py: </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\rpy2Test.py", line 2, in &lt;module&gt;
      from rpy2 import robjects
    File "C:\Python27\lib\site-packages\rpy2\robjects\__init__.py", line 14, in &lt;module&gt;
      import rpy2.rinterface as rinterface
    File "C:\Python27\lib\site-packages\rpy2\rinterface\__init__.py", line 79, in &lt;module&gt;
      raise RuntimeError("Unable to locate R.dll within %s" % R_HOME)
  RuntimeError: Unable to locate R.dll within C:Program Files\R\R-3.2.0
  </code></pre>
  
  <p>I have tried copying and pasting this: </p>
  
  <pre><code>if os.path.exists(os.path.join(R_HOME, 'lib')):             ## ADDED ##
      os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin')    ## ADDED ##
      os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules')    ## ADDED ##
      os.environ['PATH'] += ';' + os.path.join(R_HOME, 'lib')    ## ADDED ##
  else:                                   ## ADDED ##
      os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin', 'i386')     ## ADDED ##
      os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules', 'i386') ## ADDED ##
      os.environ['PATH'] += ';' + os.path.join(R_HOME, 'library')     ## ADDED ##
  
  # Load the R dll using the explicit path
  # First try the bin dir:
  Rlib = os.path.join(R_HOME, 'bin', 'R.dll')
  # Try bin/i386 subdirectory seen in R 2.12.0                ## ADDED ##
  if not os.path.exists(Rlib):                        ## ADDED ##
      Rlib = os.path.join(R_HOME, 'bin', 'i386', 'R.dll')         ## ADDED ##
  </code></pre>
  
  <p>into rinterface\__init__.py, but this did nothing.</p>
  
  <p>I have also tried copying everything from the bin\i386 folder into the bin folder, but still makes no difference.</p>
  
  <p>How do I get rpy2 to find r.dll?</p>