Jason
Jason

Reputation: 181

import rpy2.rinterface throwing errors in Python3.5

I've just reinstalled rpy2 with Python3.5 and I am having difficulty figuring out why the module cannot find the "R-Home". I have installed R on my computer already. Should I try reinstalling R or another method? Some help would be much appreciated here!

import rpy2.rinterface
Traceback (most recent call last):

File "<ipython-input-7-676c977874d9>", line 1, in <module>
import rpy2.rinterface

File "/Users/JasonDucker/anaconda/lib/python3.5/site-packages/rpy2/rinterface/__init__.py", line 16, in <module>
tmp = subprocess.check_output(("R", "RHOME"), universal_newlines=True)

File "/Users/JasonDucker/anaconda/lib/python3.5/subprocess.py", line 629, in check_output
**kwargs).stdout

File "/Users/JasonDucker/anaconda/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:

File "/Users/JasonDucker/anaconda/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)

File "/Users/JasonDucker/anaconda/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'R'

Upvotes: 1

Views: 647

Answers (1)

lgautier
lgautier

Reputation: 11545

This means that there is no executable in the PATH when python is calling "R RHOME" in a subprocess.

To overcome this add the path to R to your PATH. For example: export PATH=/usr/local/some/place/bin:${PATH}

Upvotes: 1

Related Questions