trouble installing rpy2 on win7 (R 2.12, Python 2.5)
I know I'm a little late to the party, but I had the same problem and got it working on Windows 7 by doing the install via conda
conda install --channel https://conda.binstar.org/joshadel rpy2
I have encountered a similar problem trying to use rpy2 with R 2.12 and Python 2.6 (as recommended by the rpy2 documentation).
It seems that windows binaries from http://cran.r-project.org/bin/windows/base/R-2.12.1-win.exe install the required R.dll in a directory not expected by rpy2.
I have copied all the files from R\R-2.12.1\bin\i386 to the bin directory, set an environnement variable R_HOME pointing to R\R-2.12.1 and it then worked.
I've encountered a somewhat different but related installation problem and finally found a solution at http://www.mail-archive.com/rpy-list@lists.sourceforge.net/msg02817.html
After I installed rpy2 2.0.8 via rpy2-2.0.8.win32-py2.6.msi (windows 7 (64bit), python 2.6, R 2.14 (both 32bit and 64bit, via RAndFriendsSetup2140V3.2-1-1.exe)), and tried to import rpy2 within python console, I got the exception:
Unable to locate R.dll
Adding the following lines to rinterface/__init__.py made it work:
if os.path.exists(os.path.join(R_HOME, 'lib')): ## ADDED ## os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin') os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules') os.environ['PATH'] += ';' + os.path.join(R_HOME, 'lib')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 ### Then the lib dir:if not os.path.exists(Rlib): Rlib = os.path.join(R_HOME, 'lib', 'R.dll')# Otherwise fail out!if not os.path.exists(Rlib): raise RuntimeError("Unable to locate R.dll within %s" % R_HOME)
It turns out that the R.dll is moved but the __init__.py is not updated accordingly. So simply editing the __init__.py file will get things right.
Then I tried to replicate Taj G's situation, and I did it.After adding "your_R_installation_dir\bin\i386" into the windows environment variable PATH, the old error disappeared but new one came:
ValueError: Invalid substring in string
It seems that some additional pieces need to be installed and a C/C++ compiler needs to be correctly configured. I gave up here. Using easy_install to build rpy2 from source seems really tricky on windows and not officially support at present.
Although rpy2 2.0.8 is not a full-fledged version compared with 2.2.4, it is the latest version with standard windows installer on sourceforge. For now, it is the easy choice.