7

When I do from rpy2.robjects import r I get an error:

>>> from rpy2.robjects import r
Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.6/dist-packages/rpy2/robjects/__init__.py", line 27, in <module> from . import language
      File "/usr/local/lib/python3.6/dist-packages/rpy2/robjects/language.py", line 16, in <module> _str2lang = ri.baseenv['str2lang']
      File "/usr/local/lib/python3.6/dist-packages/rpy2/rinterface_lib/conversion.py", line 44, in _ cdata = function(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/rpy2/rinterface_lib/_rinterface_capi.py", line 282, in _robj = function(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/rpy2/rinterface_lib/sexp.py", line 355, in __getitem__
    raise KeyError("'%s' not found" % key)
KeyError: "'str2lang' not found"

But when I downgrade to version 3.2.0 everything works fine.

Any thoughts?

(Ubuntu 18.04, Python 3.6.8, rpy 3.3.2)

Parzival
  • 2,004
  • 4
  • 33
  • 47
  • 1
    rpy2, just like other software, may make some assumptions about the software versions it pairs with. Maybe `str2lang` is an API entry point that changed? Ubuntu 18.04 is 2+ years old so some things may have changed. To a first approximation I would recomment `sudo apt install python3-rpy2` to get the packaged version. (Disclaimer: I am the rpy2 maintainer for Debian and have worked with the upstream author Laurent on this for a dozen years. It is high-quality software.) – Dirk Eddelbuettel Apr 28 '20 at 22:53
  • It's high quality software indeed - I've been using it for years, in several different applications, and it's a life-saver. :-) I have no control over the Ubuntu version, but I'll try the packaged version then. – Parzival Apr 28 '20 at 22:59
  • 1
    To some extent I understand you desire for a new version---all my R packages are directly from CRAN. But I take for example the entire Python stack 'as is' from my distro. I personally prefer to upgrade Ubuntu every six months. To me an excellent compromise between stability and currentness. – Dirk Eddelbuettel Apr 28 '20 at 23:01
  • 6
    `str2lang` is in R>=3.6, and its use in rpy2 started with release 3.3.0. I did not realize that this would be an issue so I'll probably make a fix for the next release in the 3.3.x series. On the other hand, ubuntu 20.04 is just out... – lgautier Apr 29 '20 at 01:08
  • Same problem with rpy2 ver 3.3.2 on Windows 10 using python 3.8.3 from Anaconda. Downgrading to 3.2.0 failed (using conda and pip). – Graham G Sep 17 '20 at 08:43

0 Answers0