0

I've been able to install rpy2 via conda:

conda install -c r rpy2  

However, the only function that works is:

import rpy2

I confirm I'm running: rpy v 2.9.0

3.5.2 |Anaconda custom (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]

Window 10

Error example:

from rpy2 import robjects

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-46-1f019d00d232> in <module>()
----> 1 from rpy2 import robjects

C:\Users\cfeld\AppData\Local\Continuum\Anaconda3\lib\site-packages\rpy2-2.9.0-py3.5-win-amd64.egg\rpy2\robjects\__init__.py in <module>()
     14 import itertools
     15 from datetime import datetime
---> 16 import rpy2.rinterface as rinterface
     17 import rpy2.rlike.container as rlc
     18 

C:\Users\cfeld\AppData\Local\Continuum\Anaconda3\lib\site-packages\rpy2-2.9.0-py3.5-win-amd64.egg\rpy2\rinterface\__init__.py in <module>()
     43 
     44 if sys.platform == 'win32':
---> 45     _load_r_dll(R_HOME)
     46 
     47 # cleanup the namespace

C:\Users\cfeld\AppData\Local\Continuum\Anaconda3\lib\site-packages\rpy2-2.9.0-py3.5-win-amd64.egg\rpy2\rinterface\__init__.py in _load_r_dll(r_home)
     27     if r_bin not in os.environ.get('PATH'):
     28         os.environ['PATH'] = ';'.join((os.environ.get('PATH'), r_bin, r_mod))
---> 29     ctypes.CDLL(r_dll)
     30 
     31 R_HOME = get_r_home()

C:\Users\cfeld\AppData\Local\Continuum\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    345 
    346         if handle is None:
--> 347             self._handle = _dlopen(self._name, mode)
    348         else:
    349             self._handle = handle

OSError: [WinError 126] The specified module could not be found

Any suggestions?

June
  • 720
  • 10
  • 22
  • Have you possibly installed *rpy2* to a different virtualenv? – Kevin Arseneau Dec 01 '17 at 02:38
  • I don't think I'm savvy enough to have done it (knowingly, if so :)) – June Dec 01 '17 at 02:39
  • It is unlikely you have done that accidentally, although some R packages such as `keras` do build one as part of their default install. That may not be the right path to solve your issue, though it is clear that your instance of python doesn't *see* `rpy2`. – Kevin Arseneau Dec 01 '17 at 02:47
  • Yes, I did find that I can bypass in Jupyter with: import os os.environ['R_HOME'] = 'C:/Program Files/R/R-3.4.2'; however, I'm not following how to update this in my machine. Here's my reference: https://stackoverflow.com/questions/12698877/how-to-setup-environment-variable-r-user-to-use-rpy2-in-python – June Dec 01 '17 at 02:51
  • If that solved your issue within *jupyter* then it should also work from *IPython*. According to [this](https://stackoverflow.com/questions/17573988/r-home-error-with-rpy2) it would seem that the *R_HOME* environment variable is picked up at install. Reinstalling after setting the value did solve for that person. – Kevin Arseneau Dec 03 '17 at 00:40

0 Answers0