Lucho
Lucho

Reputation: 239

Anaconda: Cannot import 'RRuntimeError' from 'rpy2.rinterface'

I am using Anaconda on Ubuntu 20.04. I have installed rpy2 with conda install rpy2 in a virtual enviroment (different from base) When I want to run from rpy2.rinterface import RRuntimeError I get the next error:

from rpy2.rinterface import RRuntimeError 

ImportError: cannot import name 'RRuntimeError' from 'rpy2.rinterface' (/home/myuser/anaconda3/envs/myenvorment/lib/python3.7/site-packages/rpy2/rinterface.py)

Upvotes: 1

Views: 923

Answers (1)

krassowski
krassowski

Reputation: 15379

You seem to use the new rpy2 version (3.x) in which RRuntimeError has moved from rpy2.rinterface to rpy2.rinterface_lib.embedded. Instead, use:

from rpy2.rinterface_lib.embedded import RRuntimeError

See an example in the latest rpy2 documentation and the 3.0 changelog which explains that rpy2.rinterface was completely rewritten for 3.x version.

Upvotes: 2

Related Questions