4

I am running Python 2.7 on Windows 7. First, I installed R and RTools, and changed the following environment variables:

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

And appended the following directories to PATH:

C:\Program Files\R\R-2.15.\bin\i386; C:\Rtools\bin

Next, I installed RPy2 through a binary executable here.

When running RPY2 through Python I get the following error:

Traceback (most recent call last):
  File "<string>", line 254, in run_nodebug
  File "C:\Python27\blaise automation.py", line 14, in <module>
    import rpy2.robjects as 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 28, in <module>
    "or install the win32 package.")
RuntimeError: No environment variable R_HOME could be found, calling the command 'R RHOME' does not return anything, and unable to import win32api or win32con, both of which being needed to retrieve where is R from the registry. You should either specify R_HOME or install the win32 package.

I've been working on this for HOURS. Does anybody have any idea how to resolve it?

My code:

import rpy2.robjects as robjects
import pywin

def main():
     robjects.r("require(foreign)")
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
  • I installed `pywin` through pip using `pip install pywin` and it was successful. However, when I do `import pywin` it says no such module. I tried downloading the 2.7 binary, but the executable cannot locate `Python 2.7` – Parseltongue Oct 14 '13 at 07:37
  • Are the lib folders 'site-packages' and 'win32' in your sys path? If not, try appending them in your script like: sys.path.append("...blabla\lib\site-packages") – johansson.lc Oct 14 '13 at 15:42
  • The rpy2 binary you downloaded and installed is quite old. Try getting it from Christoph Gohlke's site (see the doc http://rpy.sourceforge.net/rpy2/doc-2.3/html/overview.html#download ) – lgautier Oct 15 '13 at 01:09
  • I swear I went to that website a million times, and each time there was a message that said RPY2 would not be assembled because of "technical or legal reasons", but I see it now... – Parseltongue Oct 15 '13 at 05:38

0 Answers0