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 C:\Program Files\R\R-3.2.0\bin\i386
to the system path, added R_HOME as a system variable with value C:\Program Files\R\R-3.2.0
, added R_USER with value "Matt", and installed rpy2-2.3.0dev with a .exe file, which installed.
However, typing from rpy2 import robjects
gives the following error in rpy2\rinterface\__init__.py:
Traceback (most recent call last):
File "C:\Python27\rpy2Test.py", line 2, in <module>
from rpy2 import robjects
File "C:\Python27\lib\site-packages\rpy2\robjects\__init__.py", line 14, in <module>
import rpy2.rinterface as rinterface
File "C:\Python27\lib\site-packages\rpy2\rinterface\__init__.py", line 79, in <module>
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
I have tried copying and pasting this:
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 ##
into rinterface\__init__.py, but this did nothing.
I have also tried copying everything from the bin\i386 folder into the bin folder, but still makes no difference.
How do I get rpy2 to find r.dll?